ajax跨域问题
程序员文章站
2022-07-08 11:42:43
在java代码的方法里面增加响应头: @RequestMapping(value="getCode.html") @ResponseBody public List
在java代码的方法里面增加响应头:
@RequestMapping(value="getCode.html")
@ResponseBody
public List<Map<Object,Object>> getCode(ServletRequest request, ServletResponse resp) throws IOException, ServletException{
HttpServletResponse response = (HttpServletResponse) resp;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE");