springboot整合freemarker


前提:

開發工具: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、在配置文件中,設置以下兩個參數

 
        
#設定ftl文件路徑
spring.freemarker.template-loader-path=classpath:/templates
#設定靜態文件路徑,js,css
spring.mvc.static-path-pattern=/static/**

controller跳轉頁面如下:
templates/action/list.ftl頁面

 

 

 
 
        

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM