SpringBoot 出现 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

传参数,后台@RequestBody接收实体,报错:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

解决方案:添加**的内容,既可以解决问题

    function saveProjectSalary() {
        $.ajax({
            url: '<%=basePath%>/projectSalary/saveProjectSalary',
            type: 'post',
            **data: JSON.stringify($("#projectSalaryForm").serialize()),**
            **contentType:"application/json",**
            dataType: "json",
            success: (result) => {
                if (result.code == '200') {
                    alert(result)
                }
            },
            error: (e) => {
                alert(e);
            }
        });
    }
原创文章 36 获赞 11 访问量 344

猜你喜欢

转载自blog.csdn.net/wutian842929/article/details/106138152