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

原文链接: http://www.cnblogs.com/rocky-AGE-24/p/5170277.html
  fatherModule.setModuelName(HtmlUtils.htmlEscape(fatherModule.getModuelName()));
        log.info(HtmlUtils.htmlEscape(fatherModule.getModuelName()));
        log.info(fatherModule);
        String s = HtmlUtils.htmlEscape("
hello world

 

"); 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 - <span style="color:red">123sadfa</span>
2016-01-30 23:02:33 87 INFO AdminIndexAction - FatherModule [id=null, moduelName=<span style="color:red">123sadfa</span>, sort=0]
2016-01-30 23:02:33 89 INFO AdminIndexAction - <div>hello world</div><p>&nbsp;</p&gt;
2016-01-30 23:02:33 91 INFO AdminIndexAction - 
hello world

 

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

转载于:https://www.cnblogs.com/rocky-AGE-24/p/5170277.html

你可能感兴趣的:(利用Spring中的HtmlUtils.htmlEscape(input)过滤html)