后段可以接收到請(qǐng)求并且插入數(shù)據(jù)庫(kù)。但是。返回的時(shí)候就報(bào)錯(cuò)
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里模擬請(qǐng)求,設(shè)置了Content-Type,后端不會(huì)報(bào)錯(cuò)。這是為什么呢?
$.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){?????????
?????????}
});
2021-06-28
我的課程中,這個(gè)方法是套在了layui的提交方法之中的,并且最后返回false,返回false是阻止表單跳轉(zhuǎn),你看看你是不是那么做的。
2022-04-22
請(qǐng)問(wèn)解決了嗎?