SpringBoot使用jsp

  • 需要添加jsp解析器依赖

    <!-- jsp -->
    <dependency>
       <groupId>org.apache.tomcat.embed</groupId>
       <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
  • 配置资源目录

    <!-- build标签中 -->
    <!-- jsp文件资源目录 -->
    <resources>
       <resource>
          <directory>src/main/webapp</directory>
          <targetPath>META-INF/resources</targetPath>
          <includes>
             <include>**/*.*</include>
          </includes>
       </resource>
    </resources>
  • 注册视图解析器,前缀后缀

    spring:
      mvc:
        view:
          prefix: /
          suffix: .jsp
https://zhhll.icu/2022/框架/springboot/基础/18.springboot使用jsp/

本文由mdnice多平台发布


bug生产者
20 声望0 粉丝