h:outputText not rendering HTML from XML response in spite of escape=“false”

情到浓时终转凉″ 提交于 2019-12-02 09:01:29

It's because your text is already escaped. The escape="false" doesn't unescape text. It just prints the text as-is instead of escaping it. However, as your text is already escaped from beginning on, it appears in escaped form. Remove the escape="false" and you'll see that it will be double-escaped. I.e. every & becomes &.

You need to unescape it beforehand. The Apache Commons Lang StringEscapeUtils may come handy.

String unescapedShortDescription = StringEscapeUtils.unescapeXml(shortDescription);

Then, you can use <h:outputText escape="false"> to print it as-is.

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