springboot用controller跳转html页面

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

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

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

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

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

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

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

打完收工。

原文地址:https://www.cnblogs.com/steveshao/p/11813385.html