如何在Primefaces中显示带有html标记的文本 [英] How can i show text with html tag in primefaces

查看:178
本文介绍了如何在Primefaces中显示带有html标记的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从< p:editor>得到一个字符串,像这样:< b>This is bold text< /b>. 我想在xhtml页面中显示<b>This is bold text</b>.我可以使用什么标签来做到这一点?

I get a String from < p:editor> like this : < b>This is bold text< /b>. I want to show <b>This is bold text</b> in xhtml page. What tag can i use to do that ?

推荐答案

使用带有escape="true"的outputText:

Use an outputText with escape="true":

<h:outputText escape="true" value="<b>This is bold</b>"/>

该问题的答案中所述:

... Facelets以<h:outputText>

因此,如果您不使用将escape属性设置为trueoutputText标签,Facelets将为您添加一个,这将转义html标签.

So, if you don't use an outputText tag with the escape attribute set to true Facelets will add one for you which will escape the html tags.

编辑:对于escape属性,我完全错了.请原谅我的无知,因为我还在学习.根据文档的escape属性:

I am completely wrong about the escape attribute. Please forgive my ignorance as I am still learning as well. According to the documentation the escape attribute:

标记,指示必须转义HTML和XML标记中敏感的字符.默认情况下,此标志设置为"true".

Flag indicating that characters that are sensitive in HTML and XML markup must be escaped. This flag is set to "true" by default.

请参阅此操作系统问题的答案以获取正确的示例.

Please see the answer to this OS question for a correct example.

这篇关于如何在Primefaces中显示带有html标记的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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