问题
Trying to figure out this issue for a long time...
I am setting a variable with a value from an Object.
<s:set name="bodyText" value='First Name "myObject.name"'/>
and trying to print it in the following ways.. None of these works.
"${bodyText}"
"<s:property value="#bodyText" />"
"${#bodyText}"
"%{bodyText}"
"%{#bodyText}"
Not sure the problem is with
I tried the following as well:
<s:set name="bodyText" value='First Name "${myObject.name}"'/>
But it did not work.
回答1:
The value attribute should be an object. OGNL uses quotes to delimit a string object, other quotes should be escaped.
And use var
attribute for variable name.
<s:set var="bodyText" value="'First Name \"myObject.name\"'"/>
<s:property value="bodyText" />
来源:https://stackoverflow.com/questions/26067412/struts2-jsp-el-concatenation-doesnt-seem-to-work