How can I access method/field, using the following syntax:
${object.foo}
?
What i want is:
if there is a public field, named foo, then it's value returns,
else if there is a getter, named getFoo(), then it calls and result of call returns,
else if there is a method, named foo(), then it calls and result of call returns.
Is it possible in Freemarker?
标签:
freemarker
相关问题
- How to remove duplicate elements in a array using
- test if string can be converted to a number in Fre
- Treat a java.lang.Iterable as a #list expression i
- Invoke Java method with parameters from Freemarker
- Struts 2 + Sitemesh 3 integration - NPE in Freemar
相关文章
- Keycloak Remove First Name and Last Name fields on
- freemarker cannot handle request for '/' o
- How do I use a template code generator (eg freemar
- Freemarker does not assign staticUtil
- java》freemarker配置问题
- Better template language needed [closed]
- Freemarker print date in template
- Sandboxing Java / Groovy / Freemarker Code - Preve
Since you can write your own
ObjectWrapper
implementation it's possible, although if you need more thanobject.foo
to work (like, exposing methods etc.) writing an object wrapper can be a lot of work. So, maybe a good compromise is usingDefaultObjectWrapper
orBeansWrapper
. Where you configure FreeMarker:The priorities aren't exactly what you wanted though.
object.foo
will try things in this order:getFoo()
,foo()
,foo