何方社区
  • -

521

44 网友分享了链接

XssFilter Jsoup 富文本过滤后 @RequestBody 解析json 失败

2020-08-28 08:07:56

在过滤器里先先解析成json对象,递归属性值,把每一个属性分别过滤

然后再转成byte放到请求体里即可啦

差不多长这样
//xss过滤
JSONObject jsonObject = JSON.parseObject(json);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
if (entry.getValue() != null) {
if (entry.getValue() instanceof String) {
String a = xssEncode(entry.getValue().toString());
entry.setValue(a);
}
}
jsonObject.put(entry.getKey(), entry.getValue());
}
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8));

    文章最多点击量
  1. 劝学-先秦-荀子 0
  2. 随记 0
  3. MySQL8如何设置表名大小写不敏感? 1
  4. quartz 表名应该大写还是小写 0
  5. CentOS8下安装mysql8 10
  6. Nginx启动报错:could not open error log file: open() "/usr/local/nginx/logs/error.log" failed 3
  7. mysql修改密码 4
  8. mysql如果没有就插入,如果有就更新 1
  9. BIO、NIO 和 AIO 的区别? 0
  10. 记一次linux ssh密钥登陆失败的解决方式 2
  11. 搭建Git服务器 1
  12. 如何在CentOS中开启Swap 5
  13. 《失控》图书推荐 3
  14. Netty 的高性能表现在哪些方面? 0
  15. Netty 的零拷贝实现? 3
  16. 如何选择序列化协议? 1
  17. 了解哪几种序列化协议? 1
  18. Netty 的线程模型? 0
  19. Netty 的特点? 4
  20. NIO 的组成? 0
  21. XssFilter Jsoup 富文本过滤后 @RequestBody 解析json 失败 4
  22. 不能反向序列化 0
  23. 网站待优化 0
  24. Kafka面试题 2
  25. nacos配置管理 4
  26. 前端js防抖 3
  27. Docker学习0001 40
  28. 待整理todo 1
  29. shell重启java应用 0
  30. 调整 ubuntu swap 大小 2
使用本站请开启cookie和JavaScript