亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2006 | 回復(fù): 1
打印 上一主題 下一主題

Spring Cloud Spring Boot mybatis分布式微服務(wù)云架構(gòu)(八)開(kāi)發(fā)Web應(yīng)用(2) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2018-06-13 11:23 |只看該作者 |倒序?yàn)g覽
在完成配置之后,舉一個(gè)簡(jiǎn)單的例子,在快速入門(mén)工程的基礎(chǔ)上,舉一個(gè)簡(jiǎn)單的示例來(lái)通過(guò)Thymeleaf渲染一個(gè)頁(yè)面。
  1. @Controller
  2. public class HelloController {

  3.     @RequestMapping("/")
  4.     public String index(ModelMap map) {
  5.         // 加入一個(gè)屬性,用來(lái)在模板中讀取
  6.         map.addAttribute("host", "http://blog.didispace.com");
  7.         // return模板文件的名稱,對(duì)應(yīng)src/main/resources/templates/index.html
  8.         return "index";  
  9.     }

  10. }
復(fù)制代碼
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4.     <meta charset="UTF-8" />
  5.     <title></title>
  6. </head>
  7. <body>
  8. <h1 th:text="${host}">Hello World</h1>
  9. </body>
  10. </html>
復(fù)制代碼

如上頁(yè)面,直接打開(kāi)html頁(yè)面展現(xiàn)Hello World,但是啟動(dòng)程序后,訪問(wèn)http://localhost:8080/,則是展示Controller中host的值:http://blog.didispace.com,做到了不破壞HTML自身內(nèi)容的數(shù)據(jù)邏輯分離。

更多Thymeleaf的頁(yè)面語(yǔ)法,還請(qǐng)?jiān)L問(wèn)Thymeleaf的官方文檔查詢使用。

Thymeleaf的默認(rèn)參數(shù)配置

如有需要修改默認(rèn)配置的時(shí)候,只需復(fù)制下面要修改的屬性到application.properties中,并修改成需要的值,如修改模板文件的擴(kuò)展名,修改默認(rèn)的模板路徑等。

  1. # Enable template caching.
  2. spring.thymeleaf.cache=true
  3. # Check that the templates location exists.
  4. spring.thymeleaf.check-template-location=true
  5. # Content-Type value.
  6. spring.thymeleaf.content-type=text/html
  7. # Enable MVC Thymeleaf view resolution.
  8. spring.thymeleaf.enabled=true
  9. # Template encoding.
  10. spring.thymeleaf.encoding=UTF-8
  11. # Comma-separated list of view names that should be excluded from resolution.
  12. spring.thymeleaf.excluded-view-names=
  13. # Template mode to be applied to templates. See also StandardTemplateModeHandlers.
  14. spring.thymeleaf.mode=HTML5
  15. # Prefix that gets prepended to view names when building a URL.
  16. spring.thymeleaf.prefix=classpath:/templates/
  17. # Suffix that gets appended to view names when building a URL.
  18. spring.thymeleaf.suffix=.html  spring.thymeleaf.template-resolver-order= # Order of the template resolver in the chain. spring.thymeleaf.view-names= # Comma-separated list of view names that can be resolved.
復(fù)制代碼
支持JSP的配置

Spring Boot并不建議使用,但如果一定要使用,可以參考此工程作為腳手架:JSP支持


論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2018-06-13 11:23 |只看該作者
對(duì)源碼感興趣的朋友可以一起交流~~
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP