How to include HTML in OGNL expression language in Struts 2

雨燕双飞 提交于 2020-01-14 02:48:21

问题


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.


回答1:


You can turn off escape html symbols when printing to out

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


来源:https://stackoverflow.com/questions/26684025/how-to-include-html-in-ognl-expression-language-in-struts-2

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