一.pom文件修改
<artifactId>spring-boot-sample-web-jsp</artifactId>
<!-- 打包方式改成war -->
<packaging>war</packaging>
<!-- 设置jsp支持 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- Provided -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- 设置jsp支持 end -->
二.补全项目结构

三.application.properties
#设置支持jsp
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
#关闭默认模板引擎(设置支持jsp)
spring.thymeleaf.cache=false
spring.thymeleaf.enabled=false
四.springBoot启动类
package com.miracle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication // 支持jsp 需要继承 SpringBootServletInitializer
public class Springsecurity01Application extends SpringBootServletInitializer {
// 支持jsp 重写configure方法
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Springsecurity01Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Springsecurity01Application.class, args);
}
}