问题描述
我正在使用struts2.我正在使用OGNL表达式语言在JSP页面中对集合进行projection
.
I am working on struts 2. I was doing a projection
of a collection in my JSP page using OGNL expression language.
我在action
类中有1个基于列表的集合,我可以在JSP页面上像这样进行访问:
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>
我想要这样的输出:
rajiv --- N.Delhi
rajiv --- N.Delhi
nakul --- 孟买
vinay --- Banglore
vinay --- Banglore
//"---"为粗体.
但是我在<s:iterator value="">
中的<b></b>
标签没有被接受.它是这样打印的:
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
我想知道有什么方法可以在OGNL表达式中启用HTML.
I want to know is there any way to enable HTML in OGNL expression.
推荐答案
您可以在打印输出时关闭转义html符号
You can turn off escape html symbols when printing to out
<s:property escapeHtml="false"/><br>
这篇关于如何在Struts 2中以OGNL表达式语言包括HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!