springboot整合freemarker詳解
更新時間:2017年05月17日 14:36:09 作者:張楠楠
本篇文章主要介紹了springboot整合freemarker詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
前提:
開發(fā)工具:idea
框架:spring boot、maven
1、pom文件添加依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> <version>1.4.1.RELEASE</version> </dependency>
2、新建spring web項目,會自動生成application.properties.
使用application.properties配置文件之后,spring boot啟動時,會自動把配置信息讀取到spring容器中,并覆蓋spring boot的默認配置。
3、在配置文件中,設置以下兩個參數(shù)
#設定ftl文件路徑 spring.freemarker.template-loader-path=classpath:/templates #設定靜態(tài)文件路徑,js,css等 spring.mvc.static-path-pattern=/static/**
controller跳轉(zhuǎn)頁面如下:
templates/action/list.ftl頁面
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
帶你了解Java數(shù)據(jù)結(jié)構(gòu)和算法之隊列
這篇文章主要為大家介紹了Java數(shù)據(jù)結(jié)構(gòu)和算法之隊列,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-01-01