后端解决跨域问题

if(req.getRemoteHost().equals("192.168.2.29") ) {
                response.setHeader("Access-Control-Allow-Origin","http://192.168.2.29:8080");
            }else if( req.getRemoteHost().equals("192.168.2.83")) {
                response.setHeader("Access-Control-Allow-Origin","http://192.168.2.83:8080");
            }else if (req.getRemoteHost().equals("192.168.2.91")){
                response.setHeader("Access-Control-Allow-Origin","http://192.168.2.91:8080");
            }
            response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
            response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
            response.setHeader("Access-Control-Allow-Credentials", " true");

给指定的主机允许跨域

你可能感兴趣的:(服务器)