freemarker 自定义标签
有两种方法,一种是Spring注解添加自定义标签 一种的编码添加自定义标签
第一种:编码添加自定义标签
步骤一:添加自定义解析器
创建一个类继承 FreeMarkerConfigurer 类.重写afterPropertiesSet方法
示例:
@Override
public void afterPropertiesSet() throws IOException, TemplateException {
super.afterPropertiesSet();
this.getConfiguration().setSharedVariable("boolean",
new BooleanDirective());
}
setSharedVariable() 第一个是你freemaker要使用的标签名称 ,可以自定义 ,第二个是你实现的自定义标签
配置解析器
<bean class="这个class改成自定义的解析
转载请注明原文地址: https://ju.6miu.com/read-666003.html