springboot使用 jsp和html的配置

目录结构

在这里插入图片描述

springboot 使用html需要配置 maven依赖

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

在这里插入图片描述
使用这个就可以访问 resources/templates/test.html

springboot 使用jsp需要配置 maven依赖

 <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

application.properties配置

spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp

创建 webapp/WEB-INF 目录

在这里插入图片描述
使用这个就可以访问 /webapp/WEB-INF/12.jsp

猜你喜欢

转载自blog.csdn.net/weixin_43113795/article/details/84654720