后段可以接收到请求并且插入数据库。但是。返回的时候就报错
2021-06-16 20:35:41.508 WARN 6105 --- [nio-8088-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]
然后去postman里模拟请求,设置了Content-Type,后端不会报错。这是为什么呢?
$.ajax({
url:data.form.action,
async:false,
type:'POST',
dataType:"json",
cache:false,
contentType:'application/json;charset=utf-8',
data:JSON.stringify(data.field),
success:function(res){
console.log("ccccc")
if(res.code==0){
layer.closeAll();
query();
}else{
layer.alert(res.msg);
}
},error: function(err){
}
});