3-springboot项目使用jsp

1、在pom.xml文件中配置依赖项

<!--前端页面使用JSP-->
<!--引入Spring Boot内嵌的TomcatJSP的解析包-->
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!--jstl标签依赖的jarstart -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
<!--jstl标签依赖的jarend -->

2、在application.properties文件配置spring mvc的视图展示为jsp:

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

3、src/main 下创建一个webapp目录,然后在该目录下新建jsp页面

4、Maven的pom.xml中配置页面编译位置

<build>
<resources>

<resource>
    <directory>src/main/webapp</directory>
    <targetPath>META-INF/resources</targetPath>
    <includes>
        <include>**/*.*</include>
    </includes>
</resource>

 </resource>
</resources>

springboot使用jsp报404错误的几种解决方案:
https://blog.51cto.com/liaozhiweiblog/5298075

posted on 2023-03-20 14:43  companion  阅读(27)  评论(0编辑  收藏  举报