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

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

SpringBoot整合模板引擎過程代碼實例

瀏覽:3日期:2023-05-04 17:34:35

一、SpringBoot整合freemarker:

1.引入freemarker模板依賴:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> <version>1.5.9.RELEASE</version></dependency>

2.配置application.properties:

#freemarker 靜態資源配置#設定ftl文件路徑spring.freemarker.template-loader-path=classpath:/templates#關閉緩存,還是刷新,上線生產環境需要改為truespring.freemarker.cache=falsespring.freemarker.charset=utf-8spring.freemarker.check-template-location=truespring.freemarker.content-type=text/htmlspring.freemarker.expose-request-attributes=truespring.freemarker.expose-session-attributes=truespring.freemarker.request-context-attribute=requestspring.freemarker.suffix=.ftl

3.在resources目錄下建個目錄叫templates,在這個目錄下新建一個以.ftl結尾的文件,并且將html代碼復制進去,在controller層返回這個視圖

二、SpringBoot整合thymeleaf

1.引入thymeleaf模板依賴

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <version>1.5.9.RELEASE</version></dependency>

2.配置application.properties:

#thymeleaf靜態資源配置spring.thymeleaf.prefix=classpath:/templates/spring.thymeleaf.suffix=.htmlspring.thymeleaf.mode=HTML5spring.thymeleaf.encoding=UTF-8spring.thymeleaf.content-type=text/html#關閉緩存,即時刷新,上線生產環境需要改為truespring.thymeleaf.cache=true

3.在resoureces下新建個目錄templates在里面編寫html文件,具體的thymeleaf標簽語法這里就不做介紹了。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 乌鲁木齐市| 工布江达县| 茶陵县| 扎兰屯市| 六枝特区| 宁国市| 新营市| 四子王旗| 宾阳县| 仪陇县| 云霄县| 西藏| 凤山县| 丽水市| 太保市| 鄂尔多斯市| 顺义区| 炉霍县| 于都县| 镇原县| 宾阳县| 武汉市| 玛多县| 黔西| 栖霞市| 黔江区| 和硕县| 平泉县| 武陟县| 东兰县| 济源市| 乾安县| 蒙阴县| 郑州市| 合山市| 通河县| 新竹市| 富蕴县| 甘南县| 醴陵市| 长白|