0
点赞
收藏
分享

微信扫一扫

spring-boot-sample-web-jsp

杰森wang 2022-08-29 阅读 63

 

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​​

 



举报

相关推荐

0 条评论