Content type not supported

来源:7-2 客户新增二

Amourxxxx

2021-06-16 20:40

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


写回答 关注

2回答

  • 老猿
    2021-06-28 09:55:11

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

  • qq_热带鱼_ayBNO7
    2022-04-22 16:37:15

    请问解决了吗?


MyBatis-Plus + SpringBoot实现简单权限管理

通过实战项目掌握MyBatis-Plus应用!

12792 学习 · 133 问题

查看课程

相似问题