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

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

springboot用controller跳轉html頁面的實現

瀏覽:132日期: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
相關文章:
主站蜘蛛池模板: 民勤县| 依兰县| 嘉峪关市| 安图县| 平凉市| 溧水县| 云浮市| 青神县| 民和| 巩留县| 建湖县| SHOW| 彰化市| 通辽市| 石阡县| 明溪县| 墨竹工卡县| 进贤县| 宜黄县| 都江堰市| 顺平县| 平和县| 赤壁市| 垫江县| 新余市| 吉林市| 临城县| 刚察县| 东阿县| 灵石县| 荃湾区| 临城县| 云南省| 宜春市| 喀喇沁旗| 新兴县| 清新县| 陇西县| 新野县| 湄潭县| 高安市|