如何修复xss漏洞

857
2021/2/7 10:52:22
栏目: 网络安全
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

如何修复xss漏洞

通过在项目中配置xss过滤器修复xss漏洞,具体方法如下:

import java.io.IOException;

import javax.servlet.Filter;

import javax.servlet.FilterChain;

import javax.servlet.FilterConfig;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;

/*

*配置XSS过滤器

*/

public class XSSFilter implements Filter {

@Override

public void init(FilterConfig filterConfig) throws ServletException {

}

@Override

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

throws IOException, ServletException {

chain.doFilter(new XSSRequestWrapper((HttpServletRequest) request), response);

}

@Override

public void destroy() {

}

}

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: java如何修复xss漏洞