跨站脚本攻击XSS案例:
跨站脚本攻击XSS案例及其解决方案_xss攻击案例-CSDN博客
Java集成:
1、引入maven
<!--OWASP ESAPI,防御 XSS跨站攻击--><dependency><groupId>org.owasp.esapi</groupId><artifactId>esapi</artifactId><version>2.5.3.1</version></dependency>
2、引入esapi的配置文件
Release 2.5.2.0 · ESAPI/esapi-java-legacy · GitHub

3、测试
public static void main(String[] args) {String s = ESAPI.encoder().encodeForHTML("<a href='sdfs'></a> < script > alert(); </ script >");System.out.println("对html进行转码:"+s);s = ESAPI.encoder().encodeForSQL(new MySQLCodec(MySQLCodec.Mode.STANDARD),"select * from nihao");System.out.println("对MySQL的SQL转码:"+s);s = ESAPI.encoder().decodeForHTML(s);System.out.println("对html进行解码:"+s);}


4、其他的操作等:
WEB安全-ESAPI_esapi-2.5.2.0-configuration.jar下载-CSDN博客