天天看點

Spring boot內建Httl模闆引擎Spring boot 1.5.3內建Httl模闆引擎

Spring boot 1.5.3內建Httl模闆引擎

兩天時間花在這裡了,還不算之前在新版SpringMVC中內建Httl

整理下思路:

剛開始使用@Restcontroller 導緻傳回直接json化 沒有轉發到httl引擎

實際問題是:使用Spring boot内嵌引擎模式之後,配置檔案需要使用classpath方式加載,而不是servletContext方式加載

剛開始修改時候把httl.properties增加classpath 可以解決httl.properties加載,但是無法解決模闆加載路徑,後來使用新的Engine和新的ViewReslover是要避免mode=web,而是用classpath來加載Resouce,但是這也就無法使用Servlet進行輸出.是以使用直接指定loader的方式解決問題.

樣例項目:http://git.oschina.net/jaco2016/boot_httl

繼續閱讀