Search code examples
javajspstruts2strutsognl

How to concatenate two Boolean values with OGNL in Struts 2?


I have two variables set like this:

<s:set var="A" value="true" />
<s:set var="B" value="false" />

I want to generate the HTML below with a custom attribute info like this :

<td info="truefalse">&#160;</td>

I tried the following lines in my JSP file but I can't get true next to false:

<td info="<s:property value="#A?'true':'false'+#B?'true':'false'""/>&#160;</td>

outputs: <td info="true">&#160;</td>

<td info="<s:property value="#A" /><s:property value="#B" />">&#160;</td>

outputs: <td info="false">&#160;</td>


Solution

  • OGNL uses + to concatenate strings. Having boolean values to convert to string, you should do something like

    <s:property value="%{''+#A+#B}"/>