STRINGESCAPEUTILS.UNESCAPEHTML4 (
"Org.apache.commons.lang.StringEscapeUtils.escapeHtml (str)"
"Stringescapeutils"
String str = "<a href= ' http://www.baidu.com ' >baidu</a><script>";
/* *
* Htmlutils of Spring is escaped
*/
//<a href=& #39;http://www.baidu.com& #39; >baidu< ;/a><script>
System.out.println (Org.springframework.web.util.HtmlUtils.htmlEscape (str));
//<a href=& #39;http://www.baidu.com& #39; >baidu</a><script>
System.out.println ( Org.springframework.web.util.HtmlUtils.htmlEscapeDecimal (str));
//& #x3c; a href=& #x27;http://www.baidu.com& #x27;& #x3e;baidu& #x3c;/a& #x3e;& #x3c; script& #x3e;
System.out.println (Org.springframework.web.util.HtmlUtils.htmlEscapeHex (str));
/**
* Spring htmlutils for restore
*/
//<a href= ' http://www.baidu.com ' >baidu</a><script>
System.out.println (Org.springframework.web.util.HtmlUtils.htmlUnescape ("<a href=& #39; http:// www.baidu.com& #39;>baidu</a><script> "));
//<a href= ' http://www.baidu.com ' >baidu</a><script>
System.out.println ( Org.springframework.web.util.HtmlUtils.htmlUnescape ("<a href=& #39;http://www.baidu.com& #39; >baidu </a><script> "));
//& #60; a href= ' http://www.baidu.com ' & #62;baidu& #60;/a& #62;& #60;script& #62;
System.out.println (Org.springframework.web.util.HtmlUtils.htmlUnescape ("& #x3c; a href=& #x27; http:// www.baidu.com& #x27;& #x3e;baidu& #x3c;/a& #x3e;& #x3c;script& #x3e; "));
/**
* Stringescapeutils of Apache is escaped
*/
<a href= ' http://www.baidu.com ' >baidu</a><script>
SYSTEM.OUT.PRINTLN (org.apache.commons.lang.StringEscapeUtils.escapeHtml (str));
/**
* Apache's stringescapeutils to restore
*/
& #60, a href= ' http://www.baidu.com ' & #62;baidu& #60;/a& #62;& #60;script& #62;
System.out.println (org.apache.commons.lang.StringEscapeUtils.unescapeHtml ("<a href=" http://www.baidu.com ' >baidu</a><script> '));
Rich Text Save Escape STRINGESCAPEUTILS.UNESCAPEHTML4 (