spring Boot框架接收AJAX的JSON数据时,报错 WARN 3464 --- [nio-8080-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported。
一、如果你用的是POST测试软件,例如AipPost传的json,那你要将数据格式改为raw-JSON(application/json)。
2、如果你是JS文件传值,需要在AJAX中配置contentType: 'application/json',如图
3、如果还不行,可能是你JSON格式不对,去json.cn网站验证格式的正确性。JSON.stringify中的data数据格式如上图。