SpringBoot整合JSP
作者:互联网
(1)导入依赖
<!--JSP依赖-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
(2)创建index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
this is index page
</body>
</html>
(3) 设置工作目录
设置工作目录,如果在IDEA中项目结构为聚合工程,那么在运行jsp是需要指定路径。如果项目结构为独立项目则不需要。
(4)controller层
package com.msb.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class PageController {
@RequestMapping("/{uri}")
public String getPage(@PathVariable("uri") String uri){
return uri;
}
}
(5)在application.yml中配置信息
mvc:
view:
prefix: /WEB-INF/
suffix: .jsp
标签:SpringBoot,uri,springframework,JSP,整合,import,org,jsp,PathVariable 来源: https://blog.csdn.net/m0_61572422/article/details/122603787