freemarker模板加載路徑


1. freemarker 配置 模板加載路徑

   application.yml

 #    freemarker
freemarker:
suffix: .ftl
content-type: text/html
charset: UTF-8
template-loader-path: classpath:/views/
settings:
classic_compatible: true


文件目錄如下

要求 :子目錄(/views/user)中的password.ftl加載父目錄的common.ftl 

報錯  :Template not found for name "../common.ftl"

 

 

解決:用絕對路徑。

<#include "*/common.ftl">

*/common.ftl 會從當前文件的父目錄開始遍歷直到找到common.ftl

參考:模板加載 - FreeMarker 中文官方參考手冊 (foofun.cn)

 


免責聲明!

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



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