-
Spring HtmlUtils把HTML编码转义,可将HTML标签互相转义
- /** HTML转义 **/
- String s = HtmlUtils.htmlEscape("<div>hello world</div><p> </p>");
- System.out.println(s);
- String s2 = HtmlUtils.htmlUnescape(s);
- System.out.println(s2);
- 输出结果
- <div>hello world</div><p>&nbsp;</p>
- <div>hello world</div><p> </p>