javascript/80183.html">java 请求跨域问题解决方法实例详解
新建Util类,在Util中添加下面方法:
/* * response请求跨域公共设置 */ public static HttpServletResponse SetHttpServletResponse( HttpServletResponse response) { 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"); return response; }
在接口处调用此方法:
public String xxx(){ Util.SetHttpServletResponse(response);//解决跨域 ... return xxx;}
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
新闻热点
疑难解答
图片精选