jQuery Post,Spring Boot返回不良内容类型



我正在尝试使用EasyUi向我的Spring Boot服务器进行简单的发布请求。

请求很简单,如:

$.post('/company/delete', {
        id:row.id
    }, function(result) {
        if (result.success) {
            $('#dg').datagrid('reload'); // reload the user data
        } else {
            $.messager.show({ // show error message
                title : 'Error',
                msg : result.msg
            });
        }
    }, 'json');

和服务器端:

@ResponseBody
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public int delete(@RequestBody List<Company> JSONString){
    System.out.println("print json  "+JSONString);
    int userinfo = companyService.deleteByPrimaryKey(JSONString);
    return userinfo;
}

尽管我将JSON数据发布到服务器,但服务器返回不良内容类型:

Controller [com.supplyplatform.controller.CompanyController]
Method [public int com.supplyplatform.controller.CompanyController.delete(java.util.List<com.supplyplatform.pojo.Company>)]
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

尝试在delete方法中删除@RequestBody

最新更新