Struts2标签 <s:property escape=false>一个页面使用多个escape属性=false,只能生效一个.

 我来答
fuhaiwei
2013-07-31 · TA获得超过3409个赞
知道大有可为答主
回答量:974
采纳率:75%
帮助的人:1407万
展开全部
    <%
        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。

还是检查一下代码吧。

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式