久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

深入淺析springboot中static和templates區別

瀏覽:49日期:2023-05-30 11:29:02

靜態頁面的return默認是跳轉到/static/目錄下,當在pom.xml中引入了thymeleaf組件,動態跳轉會覆蓋默認的靜態跳轉,默認就會跳轉到/templates/下,注意看兩者return代碼也有區別,動態沒有html后綴。

1.1 在static下新建hello1.html

運行程序,瀏覽器輸入http://localhost:8080/hello1.html

深入淺析springboot中static和templates區別

so,可以在根目錄下訪問hello1.html,static目錄類似于傳統Java web中的webroot或webcontent

1.2 也可以通過接口跳轉1.2.1 添加接口

@RequestMapping('hello1')public String hello1() { return 'hello1.html';}

1.2.2 注釋掉thymeleaf依賴

<dependencies> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-thymeleaf</artifactId>--> <!--</dependency>-->

1.2.3 瀏覽器輸入http://localhost:8080/hello1

深入淺析springboot中static和templates區別

2.template目錄2.1 在template下新建hello2.html運行程序,瀏覽器輸入http://localhost:8080/hello2.html

深入淺析springboot中static和templates區別

templates下的動態頁面不能直接訪問

2.2 通過接口訪問2.2.1 添加接口

注意接口中return的頁面不包含.html后綴

@RequestMapping('hello2')public String hello2() { return 'hello2';}

2.2.2 瀏覽器輸入http://localhost:8080/hello2

深入淺析springboot中static和templates區別

3.結束語

靜態頁面的return默認是跳轉到/static/目錄下,當在pom.xml中引入了thymeleaf組件,動態跳轉會覆蓋默認的靜態跳轉,默認就會跳轉到/templates/下,注意看兩者return代碼也有區別,動態沒有html后綴。

4.總結:

改bug需要用心,掉頭發是不可避免滴!!!

到此這篇關于深入淺析springboot中static和templates區別的文章就介紹到這了,更多相關springboot static和templates區別內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 野狼在线社区2017入口 | 亚洲一区综合 | 天天操夜夜爽 | 精品96久久久久久中文字幕无 | 91成人免费看片 | 欧美日韩一 | 国产精品一区二区不卡 | 国产午夜精品一区二区三区嫩草 | 91在线视频免费观看 | 国产一区二区三区精品久久久 | 久久久久综合 | 国产永久免费 | 亚洲处破女 | 亚洲精品亚洲人成人网 | 国产欧美精品 | 日本videos18高清hd下 | www.久草 | 91亚洲精品乱码久久久久久蜜桃 | 成人免费看 | 天天拍天天操 | 夜夜撸av| www国产亚洲精品久久网站 | 国产精品一区av | 成人h动漫精品一区二区器材 | 中文字幕欧美日韩一区 | 免费观看成人毛片 | 成人免费小视频 | 鲁一鲁影院 | 国产婷婷色一区二区三区 | 亚洲毛片| 欧美日韩国产91 | 成人免费毛片嘿嘿连载视频 | 成人乱人乱一区二区三区 | 日韩av在线不卡 | 日本中文字幕一区二区 | 日韩一区欧美一区 | 久久国产精品久久 | www.成人久久| 欧美二区三区 | 亚洲成人综合在线 | 中文字幕在线免费视频 |