場景:1. 剛開始用Beetl,不是很熟悉css
2. 原來的配置出現了beetl classes!/templates錯誤(最可怕的是原來配置在idea中能夠直接跑,打成jar就用不得了)html
記錄一下當前配置,之後再修改優化。java
BeetlConf.java(官網配置):app
@Configuration public class BeetlConf { @Value("${beetl.templatesPath}") String templatesPath;//模板跟目錄 @Bean(initMethod = "init", name = "beetlConfig") public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() { BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration(); try { ClasspathResourceLoader cploder = new ClasspathResourceLoader(BeetlConf.class.getClassLoader(),templatesPath); beetlGroupUtilConfiguration.setResourceLoader(cploder); return beetlGroupUtilConfiguration; } catch (Exception e) { throw new RuntimeException(e); } } @Bean(name = "beetlViewResolver") public BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) { BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver(); beetlSpringViewResolver.setContentType("text/html;charset=UTF-8"); beetlSpringViewResolver.setOrder(0); beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration); return beetlSpringViewResolver; } }
appliaction.properties:ide
### beetl配置 ## 模板根目錄 beetl.templatesPath=/templates
Controller:學習
@RequestMapping("/home") public String home(Admin u, Model model) { return "/back/home.btl"; }
templates目錄結構:優化
loanReqList.btl中include:idea
<% include("/back/common/_css.btl"){}%>
Beetl是個好東西,不斷學習中...spa