spring boot velocity自定义指令 java

来源:互联网 发布:粉红女郎 知乎 编辑:程序博客网 时间:2024/05/29 07:35

1、创建类,继承Directive,重写getName(),getType(),render()方法

2、application.properties 中加入:

spring.velocity.properties.userdirective = com.xxx.你写的类
3.vm使用,#name()


所遇问题,

node.jjtGetChild(0);
一直报空指针,后来重写了int()方法好了,
@Overridepublic void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {    super.init(rs, context, node);}

原创粉丝点击