springboot 跨域 ajax返回值跨域

    @RequestMapping(value ="/websitePositionList", method = RequestMethod.POST)*****重要
    public Map<String,Object> 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
    }
***代表重点 直接复制就可以

猜你喜欢

转载自blog.csdn.net/weixin_42707543/article/details/88989538
今日推荐