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  :

 

 

打完收工。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM