2013-03-15 111 views
0

我正在使用struts 1.3开发应用程序。我有要求,我需要表示属性值为HTML文本。我有一个名为CommentText特性是字符串类型的,我用<bean:write>如何在jsp中将纯文本表示为html文本?

<td width="8%"><span class="formlabel"> 
    <bean:message key="ui.jsp.dashboard.news.showNews.button.message" /> 
</td> 
<td width="80%"> 
    :&nbsp;&nbsp;<bean:write name="record" property="commentText" /> 
</td> 

如何表示这个纯文本HTML文本打印属性值?

任何建议,欢迎,

感谢

回答

0

如果它放在span tag

<span>:&nbsp;&nbsp;<bean:write name="record" property="commentText" /></span>. 

,更好的与字符串类型的简单的文本使用JSTL

<c:out value="YourNormalStringHere" escapeXml="false"/> 
+0

其不是简单的字符串,在某些情况下它可能有http li nks到其他来源,我需要使这部分的文本作为超链接 – 2013-03-15 06:32:21

+0

查看更新的答案,也看看这个http://www.rgagnon.com/javadetails/java-0306.html.That是一个实用的方法转换成html.If你不愿意使用JSTl – 2013-03-15 06:55:37

+0

@Suresh,页面未找到。还有其他链接吗?会有很大的帮助 – 2013-03-15 06:59:54