av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

深入淺析springboot中static和templates區別

瀏覽:43日期: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
相關文章:
主站蜘蛛池模板: 免费av手机在线观看 | 日本久久网 | 欧美在线一区二区三区 | 欧美激情在线精品一区二区三区 | 欧美a v在线 | 一区二区高清在线观看 | 黄色网址在线免费播放 | 国产精品观看 | 久久久高清 | 久久久91精品国产一区二区三区 | 久久久久国产精品午夜一区 | 国产免费又色又爽又黄在线观看 | 久久精品小视频 | 91久久国产综合久久91精品网站 | 成人精品国产免费网站 | 成人h片在线观看 | 国产精品自拍啪啪 | 91一区二区 | 国产精品777一区二区 | 午夜国产| av特级毛片 | 成人性视频免费网站 | 成人在线精品视频 | 久久久久久久香蕉 | 午夜精品一区二区三区在线视频 | 午夜久久久久久久久久一区二区 | 欧美日韩视频在线第一区 | 亚洲第一在线视频 | 羞羞的视频在线观看 | 草久久 | av网站观看| japan25hdxxxx日本| 国产丝袜一区二区三区免费视频 | www精品美女久久久tv | 日韩av手机在线观看 | 天堂在线中文 | 成人福利网站 | 中文字幕日韩欧美 | 91视频久久 | 精品国产一区二区三区久久 | 天天操夜夜骑 |