在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");