Java:如何在Java中隐藏HTML字符实体? [英] Java: How to unescape HTML character entities in Java?
本文介绍了Java:如何在Java中隐藏HTML字符实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
& nbsp
- > ,& gt;
- > >
。
在.NET中,我们可以使用 HttpUtility.HtmlDecode
。
Java中的等价函数是什么?
解决方案 Apache Commons StringEscapeUtils.unescapeHtml4() for this:
使用包含实体的字符串
转义为包含对应于转义的
实际Unicode字符
的字符串。支持
HTML 4.0实体。
Basically I would like to decode a given Html document, and replace all special chars, such as " "
-> " "
, ">"
-> ">"
.
In .NET we can make use of HttpUtility.HtmlDecode
.
What's the equivalent function in Java?
解决方案 I have used the Apache Commons StringEscapeUtils.unescapeHtml4() for this:
Unescapes a string containing entity
escapes to a string containing the
actual Unicode characters
corresponding to the escapes. Supports
HTML 4.0 entities.
这篇关于Java:如何在Java中隐藏HTML字符实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文