How can i show text with html tag in primefaces

穿精又带淫゛_ 提交于 2019-12-12 10:45:25

问题


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 ?


回答1:


Use an outputText with escape="true":

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

As stated in the answer to this question:

...Facelets implicitly wraps inline [emphasis added] content in a component as represented by <h:outputText>

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.

Edit: 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:

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.



来源:https://stackoverflow.com/questions/7858521/how-can-i-show-text-with-html-tag-in-primefaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!