Pom文件需要配置的:
<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>
必须的配置项:
spring.view.prefix: /WEB-INF/jsp/
spring.view.suffix: .jsp
启动方式:
mvn spring-boot:run
因为如果不使用打包的方式webapp目录不在classpath下面,导致找不到jsp文件
如果要在spring boot中使用jsp,得将应用打包成war,这里有配置的example https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp