国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

springboot用controller跳轉html頁面的實現

瀏覽:30日期: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
相關文章:
主站蜘蛛池模板: 天水市| 凤阳县| 新宁县| 沐川县| 孙吴县| 武冈市| 洪湖市| 平定县| 罗甸县| 新昌县| 彭阳县| 肥东县| 子洲县| 巩留县| 高碑店市| 航空| 台州市| 盱眙县| 辽阳县| 漠河县| 葫芦岛市| 内江市| 定安县| 苏州市| 龙南县| 台山市| 杨浦区| 原平市| 吴川市| 甘谷县| 武义县| 册亨县| 多伦县| 青阳县| 临湘市| 抚顺县| 曲沃县| 和田县| 谢通门县| 阿巴嘎旗| 赤峰市|