您可以配置Jsoup的转义模式:使用
EscapeMode.xhtml将为您提供无实体输出。
这是一个完整的代码段,可以接受
str作为输入,并使用进行清理
Whitelist.simpleText():
// Parse str into a documentdocument doc = Jsoup.parse(str);// Clean the document.doc = new Cleaner(Whitelist.simpleText()).clean(doc);// Adjust escape modedoc.outputSettings().escapeMode(EscapeMode.xhtml);// Get back the string of the body.str = doc.body().html();



