java - Applying OGNL expression to a context variable -
i'm working struts2 (unexperienced developer) , i've been searching couldn't find how apply ognl expression variable stored in context.
the thing need retrieve parameter context , uppercase it. now, i've tried way sadly no luck:
<s:property value="#myvar.touppercase()" />
as works variables stored in valuestack (notation without #), don't understand why won't work stored in context..
i'm able print #myvar
content fine if dont append .touppercase()
it.
also tried workaround didn't help:
<s:property value="<s:property value="#myvar"/>.touppercase()"/>
so what's thing i'm missing? how can apply ognl expression variable stored in context?
many thanks
your variable isn't string there isn't touppercase()
method in it. solution call tostring()
before calling touppercase()
.
<s:property value="#myvar.tostring().touppercase()" />
update
actually problem here <s:set var="myvar" value="%{#parameters.myvar}"/>
since there more 1 myvar
in parameters return array of strings, if want single parameter change expression #parameters.myvar[0]
, touppercase()
work.
<s:set var="myvar" value="%{#parameters.myvar[0]}"/> <s:property value="#myvar.touppercase()" />
or
<s:set var="myvars" value="%{#parameters.myvar}"/> <s:property value="#myvars[0].touppercase()" />
Comments
Post a Comment