IT序号网

JAVA跨越加个过滤解决知识解答

developer 2021年06月13日 编程语言 143 0
public class AccessFilter implements Filter { 
 
	@Override 
	public void init(FilterConfig filterConfig) throws ServletException { 
		 
	} 
 
	@Override 
	public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException { 
		 
		HttpServletResponse response = (HttpServletResponse) res; 
        response.setHeader("Access-Control-Allow-Origin", "*"); 
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 
        response.setHeader("Access-Control-Max-Age", "3600"); 
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); 
        chain.doFilter(req, res); 
	} 
 
	@Override 
	public void destroy() { 
		 
	} 
 
} 


发布评论
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

FTP java.net.ConnectException: Connection refused: connect知识解答
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。