为了账号安全,请及时绑定邮箱和手机立即绑定

Content type not supported

后段可以接收到请求并且插入数据库。但是。返回的时候就报错
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){         
         }
});


正在回答

3 回答

我的课程中,这个方法是套在了layui的提交方法之中的,并且最后返回false,返回false是阻止表单跳转,你看看你是不是那么做的。

0 回复 有任何疑惑可以回复我~

请问解决了吗?


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

Content type not supported

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信