0%

SpringBoot使用jsp

SpringBoot使用jsp

  • 需要添加jsp解析器依赖

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <!-- build标签中 -->
    <!-- jsp文件资源目录 -->
    <resources>
    <resource>
    <directory>src/main/webapp</directory>
    <targetPath>META-INF/resources</targetPath>
    <includes>
    <include>**/*.*</include>
    </includes>
    </resource>
    </resources>
  • 注册视图解析器,前缀后缀

    1
    2
    3
    4
    5
    spring:
    mvc:
    view:
    prefix: /
    suffix: .jsp

欢迎关注我的其它发布渠道