I have a JSF page where I display data from different rss feeds. Sometimes this data contains html markup elements, but when I put them inside a p:outputLabel they are displayed on the page like plain text filled with markup elements written out. Is there a way to either ignore these elements or to render them properly? Unfortunately I haven't found much on this.

有帮助吗?

解决方案

Set the escape attribute for the control to false. The default is true to prevent interpretation of any content as html.

<p:outputLabel value="#{bean.text}" escape="false"/>

其他提示

Use escape="true" in <h:outputText>:

<h:outputText value="#{bean.text}" escape="true" />

Note that <p:outputLabel> will render a <label> HTML commponent, which should be used as label for other components like <p:inputText>. It is not for writing direct content in your HTML.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top