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

您的位置:首頁技術(shù)文章
文章詳情頁

springboot用controller跳轉(zhuǎn)html頁面的實(shí)現(xiàn)

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

在學(xué)習(xí)SpringBoot的過程中遇到一個(gè)問題,因?yàn)镾pringBoot是集成了tomcat的,所以項(xiàng)目是打成jar包,通過SpringMVC注解的方式去運(yùn)行的,所以靜態(tài)頁面就放在maven工程的resources目錄下的templates目錄下所以怎么去跳轉(zhuǎn)是個(gè)問題,現(xiàn)在就是解決這個(gè)問題

首先看項(xiàng)目結(jié)構(gòu)

springboot用controller跳轉(zhuǎn)html頁面的實(shí)現(xiàn)

pom.xml文件依賴

<!-- 1.創(chuàng)建一個(gè)Maven工程,選擇jar類型項(xiàng)目2.引入SpringBootMaven依賴。 --> <!-- Maven parent 目的,聚合工程、繼承關(guān)系 --> <!--Spring parent 目的: 統(tǒng)一整合第三方框架依賴信息 (SpringBoot 支持依賴 不需要寫版本號(hào)) --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <dependencies> <!-- -springboot 整合Web組件 整合SpringMVC 就會(huì)把傳統(tǒng)方式的SpringMVC依賴的jar全部給下載來 --> <!-- 引入spring-boot-starter-web 幫你整合好所有相關(guān)的依賴jar包 原理 maven依賴傳遞 --> <!-- 原理: spring-boot-starter-parent< 中,整合號(hào)相關(guān) 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代碼,這里為了更加的清楚項(xiàng)目結(jié)構(gòu)帶上包的路徑

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跳轉(zhuǎn)html頁面的實(shí)現(xiàn)

訪問頁面

springboot用controller跳轉(zhuǎn)html頁面的實(shí)現(xiàn)

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

到此這篇關(guān)于springboot用controller跳轉(zhuǎn)html頁面的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)springboot controller跳轉(zhuǎn)html內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 邓州市| 大邑县| 洛浦县| 陇川县| 历史| 禹州市| 水富县| 南乐县| 武汉市| 德清县| 晋宁县| 洛宁县| 门源| 昆山市| 通海县| 广德县| 宁津县| 关岭| 怀仁县| 临邑县| 德兴市| 景泰县| 辽阳市| 漳浦县| 泗水县| 吉安市| 井冈山市| 延安市| 舟山市| 扶沟县| 岳西县| 绩溪县| 河西区| 塔城市| 大渡口区| 当阳市| 绍兴县| 和平县| 安远县| 五家渠市| 义乌市|