码迷,mamicode.com
首页 > 编程语言 > 详细

利用Spring中的HtmlUtils.htmlEscape(input)过滤html

时间:2016-01-30 02:38:58      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

  fatherModule.setModuelName(HtmlUtils.htmlEscape(fatherModule.getModuelName()));
        log.info(HtmlUtils.htmlEscape(fatherModule.getModuelName()));
        log.info(fatherModule);
        String s = HtmlUtils.htmlEscape("<div>hello world</div><p>&nbsp;</p>");  
        log.info(s); 
        String s2 = HtmlUtils.htmlUnescape(s);  
        log.info(s2);   
        adminIndexService.saveFatherModule(fatherModule);
        return "redirect:"+ActionURL.ADMIN_INDEX;

运行结果

2016-01-30 23:02:33 86 INFO AdminIndexAction - &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;123sadfa&amp;lt;/span&amp;gt;
2016-01-30 23:02:33 87 INFO AdminIndexAction - FatherModule [id=null, moduelName=&lt;span style=&quot;color:red&quot;&gt;123sadfa&lt;/span&gt;, sort=0]
2016-01-30 23:02:33 89 INFO AdminIndexAction - &lt;div&gt;hello world&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
2016-01-30 23:02:33 91 INFO AdminIndexAction - <div>hello world</div><p>&nbsp;</p>

这个还需优化,这个应该只在哪些具有输入的地方进行过滤,这个怎么实现呢?

利用Spring中的HtmlUtils.htmlEscape(input)过滤html

标签:

原文地址:http://www.cnblogs.com/rocky-AGE-24/p/5170277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!