如何在Struts2中对HTML进行转义 [英] How to unescape HTML in Struts2

查看:193
本文介绍了如何在Struts2中对HTML进行转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在数据库中保存了一些基本的HTML.该HTML通过Action类中的ValueStack在JSP文件中重新显示为<s:property value="htmlcodeString"/>.

I have saved some basic HTML in a database. This HTML is via ValueStack in Action class redisplayed as <s:property value="htmlcodeString"/> in JSP file.

但是,HTML代码不会被解释,而是按原样转义并显示(例如,显示< b> BOLD</b>而不是 BOLD ).

However, the HTML code is not interpreted, but escaped and displayed as is (eg. <b>BOLD</b> is shown instead of BOLD).

我正在使用Struts2.我在互联网上发现了许多建议使用<c:out value="${text}" escapeXml="false" />.但是我不知道那是什么.如何在Struts2中使用它?

I am using Struts2. I found many recommendations on internet to use <c:out value="${text}" escapeXml="false" />. But I don't know what it is. How can I make use of it in Struts2?

推荐答案

<s:property>标签具有escapeHtml属性,默认情况下为true.

The <s:property> tag has an escapeHtml attribute which is true by default.

(希望出于明显的原因.)

<c:out>是JSTL的一部分,您可以像在其他任何Web应用程序中一样在S2中使用它,但要注意的是,由于S2请求包装,您可以使用JSP EL来访问值堆栈.

<c:out> is part of the JSTL, and you use it in S2 like in any other web app, with the caveat that it's because of an S2 request wrapper you can use JSP EL to access the value stack.

这篇关于如何在Struts2中对HTML进行转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆