![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
Struts2标签 <s:property escape=false>一个页面使用多个escape属性=false,只能生效一个.
展开全部
<%
request.setAttribute("msg", "<font color='red'>ERROR</font>");
request.setAttribute("msg2", "<font color='red'>ERROR2</font>");
%>
<s:property value="#request.msg" /><br />
<s:property value="#request.msg" escape="false" /><br />
<s:property value="#request.msg" escapeHtml="false" /><br />
<s:property value="#request.msg2" /><br />
<s:property value="#request.msg2" escape="false" /><br />
<s:property value="#request.msg2" escapeHtml="false" /><br />
效果如下:
我的struts2版本是struts-2.3.15.1。
因为最近struts2闹漏洞,所以升级到最新了。
我自己试验是没有只能生效一个的问题。
追问
这样确实没问题。页面功能:div隐藏实现,在用escape=false就出现标题所说的问题了。不知你用过没有!
追答
<style type="text/css">
div {display: none;}
</style>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
$("div").toggle();
});
});
</script>
<%
request.setAttribute("msg", "<font color='red'>ERROR</font>");
request.setAttribute("msg2", "<font color='red'>ERROR2</font>");
%>
<button>show/hide msg</button>
<div>
<s:property value="#request.msg" escapeHtml="false" />
</div>
<div>
<s:property value="#request.msg2" escapeHtml="false" />
</div>
额,隐藏的也行啊。struts2应该没有这么大的bug。
还是检查一下代码吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询