zoukankan      html  css  js  c++  java
  • 利用Spring中的HtmlUtils.htmlEscape(input)过滤html

      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>

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

  • 相关阅读:
    类例程_java战斗程序
    "类"的讲稿
    象棋中“车”的攻击范围_C#
    面向对象_方法_例题
    入门例子
    MyBatis
    MyBatis
    MyBatis
    Spring
    Hibernate学习
  • 原文地址:https://www.cnblogs.com/rocky-AGE-24/p/5170277.html
Copyright © 2011-2022 走看看