步骤如下
创建一个SpringBoot项目,打包方式为war
在Project Settings中为项目创建好webapp,和WEB-INF/web.xml
点击Edit Configurations
添加本地的Tomcat
在webapp下创建index.jsp,启动Tomcat来到index.jsp页面
简单的测试JSP页面能不能使用
index.jsp页面
<body>
<%--发送Hello请求--%>
<a href="hello">发送请求</a>
</body>
HelloController
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello";
}
}
在application.properties中配置视图解析器
# 配置视图解析器
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
hello.jsp页面
<body>
hello World
</body>