久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

springboot用controller跳轉html頁面的實現

瀏覽:12日期:2023-04-24 09:12:55

在學習SpringBoot的過程中遇到一個問題,因為SpringBoot是集成了tomcat的,所以項目是打成jar包,通過SpringMVC注解的方式去運行的,所以靜態頁面就放在maven工程的resources目錄下的templates目錄下所以怎么去跳轉是個問題,現在就是解決這個問題

首先看項目結構

springboot用controller跳轉html頁面的實現

pom.xml文件依賴

<!-- 1.創建一個Maven工程,選擇jar類型項目2.引入SpringBootMaven依賴。 --> <!-- Maven parent 目的,聚合工程、繼承關系 --> <!--Spring parent 目的: 統一整合第三方框架依賴信息 (SpringBoot 支持依賴 不需要寫版本號) --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <dependencies> <!-- -springboot 整合Web組件 整合SpringMVC 就會把傳統方式的SpringMVC依賴的jar全部給下載來 --> <!-- 引入spring-boot-starter-web 幫你整合好所有相關的依賴jar包 原理 maven依賴傳遞 --> <!-- 原理: spring-boot-starter-parent< 中,整合號相關 jar依賴信息 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies>

controller代碼,這里為了更加的清楚項目結構帶上包的路徑

package cn.hd.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class FTLIndexController { @RequestMapping('/ftlIndex') public String ftlIndex() { System.out.println('fff'); return 'user/index'; }}

html代碼直接截圖

springboot用controller跳轉html頁面的實現

訪問頁面

springboot用controller跳轉html頁面的實現

application.properties配置文件中不需要寫任何東西

到此這篇關于springboot用controller跳轉html頁面的實現的文章就介紹到這了,更多相關springboot controller跳轉html內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 泌阳县| 鸡东县| 嘉善县| 岳阳市| 子洲县| 松江区| 泽州县| 雷山县| 肥东县| 肇庆市| 灌云县| 崇仁县| 丰宁| 广宁县| 施甸县| 新和县| 常宁市| 永春县| 志丹县| 四子王旗| 佛学| 平邑县| 麻江县| 西藏| 黄山市| 湘潭市| 灵山县| 同德县| 苏尼特右旗| 纳雍县| 晋城| 菏泽市| 崇左市| 信宜市| 辉县市| 垦利县| 雷山县| 广灵县| 临江市| 靖远县| 鄄城县|