springboot项目中使用jsp

在pom文件中

1.方法一

<!-- 引入tomcate内嵌的jsp解析包-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>

<resources>
<resource>
<!-- 源文件位置-->
<directory>src/main/webapp</directory>
<!-- 编译到MATA-INF/resources-->
<targetPath>MATA-INF/resources</targetPath>
<includes>
<!-- 把那些文件编译过去 **/*.*表示全部-->
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>

properties文件中配置

spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp

2.====方法二

可以添加一个外部tomcat启动项目,tomcat启动时会自动启动springboot

properties文件中配置

扫描二维码关注公众号,回复: 10095291 查看本文章

jsp在项目中的路径,前缀

spring.mvc.view.prefix=/

后缀
spring.mvc.view.suffix=.jsp

猜你喜欢

转载自www.cnblogs.com/xianz666/p/12554059.html