java服务端Access-Control-Allow-Origin解决跨域

@RequestMapping("/getNum")
@ResponseBody
public String getNum(HttpServletResponse response){
    response.setHeader("Access-Control-Allow-Origin","*");
    Map result = new HashMap();
    result.put("name","00101004");
    String json = JSONObject.toJSON(result).toString();
    System.out.println(json);
    return json;

}

你可能感兴趣的:(浏览器)