报错:Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
后端需要Servlet来实现doOptions方法来处理这个请求。
解决方法:
在doOptions方法中添加:
response.setHeader("Access-Control-Allow-Methods", "OPTIONS, GET, POST");
response.setHeader("Access-Control-Allow-Headers", "content-type, x-requested-with");
response.setHeader("Access-Control-Max-Age", "86400");