SpringBoot如何在webapp下直接访问html,jsp

目录

一、访问html

1、添加目录

2、选择Web目录

3、修改位置和名字为src\main\webapp

效果如下:

二、访问jsp

1、向pom文件中导入依赖

2、配置yml文件


一、访问html

1、添加目录

2、选择Web目录

3、修改位置和名字为src\main\webapp

效果如下:

即可正常访问(注意加上.html哟):

二、访问jsp

1、向pom文件中导入依赖


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

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

2、配置yml文件

spring:
  resources:  #静态资源
    static-locations:
    - classpath:/META-INF/resources/
    - classpath:/resources/
    - classpath:/static/
    - classpath:/public/
    - classpath:/img/
    - classpath:/js/
    mvc:
      view:
        prefix: /
        suffix: .jsp
发布了129 篇原创文章 · 获赞 9 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41808387/article/details/104636713