IT序号网

过滤器 实现 跨域

wyy 2021年06月13日 编程语言 248 0


	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); 
	}



评论关闭
IT序号网

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