之前SSM框架,里面有webapps文件夹,用来存放前端页面和各种前端资源,现在SpringBoot中没有webapps文件夹,springboot结构如下:

springboot用controller跳转html页面

 

 

第一、resourses下文件夹public是我自己创建的,通过local host:8080/index.html可以直接访问。

第二、通过controller层访问templates中的文件夹:

步骤一、application.properties 配置中添加spring.thymeleaf.prefix=classpath:/templates/

springboot用controller跳转html页面

步骤二、pom.xml文件中添加依赖:

        <!-- 访问html文件依赖begin -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- 访问html文件依赖begin -->    

步骤三、controller层访问http://localhost:8080/test  :

springboot用controller跳转html页面

 

 

打完收工。

 

 

相关文章:

  • 2021-09-20
  • 2021-12-13
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-01-05
  • 2021-07-11
  • 2021-06-27
猜你喜欢
  • 2021-12-21
  • 2021-06-20
  • 2021-08-24
  • 2022-12-23
  • 2021-05-04
相关资源
相似解决方案