Freemarker:从模板文件(*.ftl)调用静态util方法 [英] Freemarker: call a static util method from a template file (*.ftl)
本文介绍了Freemarker:从模板文件(*.ftl)调用静态util方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
StringUtils.capatilize(myString)
。例如:
<p>You selected ${selectionString}.</p>
<p>${StringUtils.capatilize(selectionString)} is great.</p>
我是否可以以某种方式导入org.apache.commons.lang3.StringUtils
?
推荐答案
您不能#import
一个类,只能使用其他模板。
请注意,您可以使用#assign StringUtils=statics['org.apache.commons.lang3.StringUtils']
获得类似的结果,只要您将objectWrapper.getStaticModels()
Asstatics
添加到Configuration
中的共享变量集或将其添加到数据模型中。
这篇关于Freemarker:从模板文件(*.ftl)调用静态util方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文