Reputation: 125
I have a problem in my Struts 2 app.
I read the content of an iterator of an array.
The array elements are written out by an iterator:
<s:text name="#wApps.title"/>
The tag finds the correct element and evaluates it, but the resulting expression has a +
character (e.g: the array element has value: "Weather+ Free"
'), and it continues to evaluate it. Finally, it writes out value: nullnull
.
How can I skip this second evaluation?
Here is the log:
Jun 18, 2013 5:29:40 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
WARNING: The first TextProvider in the ValueStack (rs.plusnet.android.market.AndroidMarket.UI.ListCategory) could not locate the message resource with key '**Weather+ Free**'
Jun 18, 2013 5:29:40 AM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
WARNING: The default value expression 'Weather+ Free' evaluated to '**nullnull**'
Upvotes: 3
Views: 6258
Reputation: 1
This is not struts, OGNL issue. OGNL doesn't evaluate expression twice, without special syntax that include subexpressions. However the "+" sign is an operator that evaluate the expression if you enter it without quotas.
Surround with quotas the value like this to prevent evaluation.
<s:set var="title" value="'Weather+ Free'"/>
or use the value in the body like this
<s:set var="title">Weather+ Free</s:set>
to check it
<s:property value="#title"/>
Also if the value is in the action property or any other scope the double evaluation should never occur.
Upvotes: 2