Search code examples
javajspstruts2ognl

How to include HTML in OGNL expression language in Struts 2


I am working on struts 2. I was doing a projection of a collection in my JSP page using OGNL expression language.

I have 1 list based collection in my action class, that I am accessing on JSP page like this:

<s:iterator value="lsEmp.{name + '<b>---</b>' + address}"> //lsEmp is a list based collection
<s:property /><br>
</s:iterator>

I want the output like this:

rajiv --- N.Delhi

nakul --- Mumbai

vinay --- Banglore

//"---" being bold.

But my <b></b> tag in <s:iterator value=""> is not getting accepted. And it is printing as it is like this:

rajiv <b>---</b> N.Delhi

nakul <b>---</b> Mumbai

vinay <b>---</b> Banglore

I want to know is there any way to enable HTML in OGNL expression.


Solution

  • You can turn off escape html symbols when printing to out

    <s:property escapeHtml="false"/><br>