Struts2 - JSP EL - Concatenation doesn't seem to work

馋奶兔 提交于 2019-12-30 06:56:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!