springboot 跨域 ajax返回值跨域

    @RequestMapping(value ="/websitePositionList", method = RequestMethod.POST)*****重要
    public Map check2(PositionInfo positionInfo,HttpServletResponse response)throws UnsupportedEncodingException{
        response.addHeader("Access-Control-Allow-Origin", "*");***
        response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");**
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with");***
        response.addHeader("Access-Control-Max-Age", "1800");//30 min***
        return map;//返回到页面  map里面定义的XXX  到页面上直接data.XX
    }
***代表重点 直接复制就可以

你可能感兴趣的:(springboot 跨域 ajax返回值跨域)