2013-03-15 105 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