跨域的几种解决方法

1、jsonp
利用



//test2.html    接收消息页面添加message监听

3、后台拦截器进行请求头修改

 public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
                    throws Exception {
                    response.addHeader("Access-Control-Allow-Origin", "*");
       response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
                    response.addHeader("Access-Control-Allow-Headers",
                            "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,token");
                return true;
            }

4配置nginx
通过nginx来进行不同服务器的跳转
个人推荐nginx进行跨域问题解决

你可能感兴趣的:(跨域的几种解决方法)