1、SpringBoot集成JSP思路:
- 1、创建1个webapp来存放jsp页面
- 2、添加springboot工程内嵌TomCat对JSP解析的一个依赖
- 3、springboot工程指定了JSP文件编译的路径META-INF/resources
2、application.properties
server.port=8082
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp
3、index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>${data}</h1>
</body>
</html>
4、IndexController.class
package com.bjpowernode.springboot.web;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping(value = "/index")
public String myindex(Model model){
model.addAttribute("data", "SpringBoot框架集成JSP页面");
return "index";
}
}
5、运行结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b9e50de54a2f5ba4b55ab878a5eb9af8.png)