org.springframework.web.util.HtmlUtils 可以实现HTML标签及转义字符之间的转换。

示例代码:


String s = HtmlUtils.htmlEscape("<div>hello world</div><p>&nbsp;</p>");  
System.out.println(s);  
String s2 = HtmlUtils.htmlUnescape(s);  
System.out.println(s2);  

转义后如图所示:
HTML编码转义输出如图所示

标签: Spring HtmlUtils, htmlUnescape spring


阿里云优惠主机

添加新评论

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。