84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
文章:http://csjava.blog.163.com/bl...
那我用maven怎么下载这个依赖
光阴似箭催人老,日月如移越少年。
See freemarker-template-inheritance
dependencies { compile 'kr.pe.kwonnam.freemarker:freemarker-template-inheritance:0.4.RELEASE' }
@Bean public Map freemarkerLayoutDirectives() { Map freemarkerLayoutDirectives = new HashMap(); freemarkerLayoutDirectives.put("extends", new ExtendsDirective()); freemarkerLayoutDirectives.put("block", new BlockDirective()); freemarkerLayoutDirectives.put("put", new PutDirective()); return freemarkerLayoutDirectives; } @Bean public FreeMarkerConfigurer freemarkerConfig() { FreeMarkerConfigurer freemarkerConfig = new FreeMarkerConfigurer(); freemarkerConfig.setTemplateLoaderPath("/WEB-INF/ftls/"); freemarkerConfig.setDefaultEncoding("UTF-8"); Map freemarkerVariables = new HashMap(); freemarkerVariables.put("layout", freemarkerLayoutDirectives()); freemarkerConfig.setFreemarkerVariables(freemarkerVariables); return freemarkerConfig; } @Bean public ViewResolver viewResolver() { FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver(); viewResolver.setCache(false); viewResolver.setPrefix(""); viewResolver.setSuffix(".ftl"); viewResolver.setContentType("text/html; charset=utf-8"); return viewResolver; }
Base Layout <@layout.block name="head"> @layout.block> <@layout.block name="header"> Base Layout @layout.block> <@layout.block name="contents"> Contents will be here @layout.block> <@layout.block name="footer"> Footer base @layout.block>
<@layout.block name="contents">
Footer base
<@layout.extends name="layouts/base.ftl"> <@layout.put block="head"> @layout.put> <@layout.put block="header" type="prepend"> Index Page @layout.put> <@layout.put block="contents"> blah.. blah.. @layout.put> <@layout.put block="footer" type="replace"> Footer replaced by index @layout.put> @layout.extends>
blah.. blah..
Footer replaced by index
See freemarker-template-inheritance
Gradle dependencies
Spring 配置
使用
base.ftl: layout
view.ftl : contents