我正在尝试配置一个基于 extjs 作为前端和 Spring 作为后端的小型应用程序。因此,要从 extjs 与服务器通信,我们需要在 store 中配置代理编写器。我的代理配置如下所示:
proxy : {
type: 'rest',
reader: {
type: 'json',
idProperty: 'id',
root: 'data',
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'message'
},
writer: {
type: 'json',
allowSingle: true,
writeAllFields: true,
root: 'data'
},
api: {
read: 'countries',
create: 'country/add',
update: 'country/update',
destroy: 'country/delete'
}
}
这是 Spring Controller 中的 @RequestMapping:
@ResponseStatus(value = HttpStatus.OK)
@RequestMapping(value = COUNTRY_PATH + DELETE_PATH + SLASH + DELETE_ID_PARAM, method = RequestMethod.DELETE)
public void delete(@PathVariable(DELETE_ID_PARAM) Integer deleteId, @RequestParam Object data) {
System.out.println(data.toString());
countryService.deleteCountry(deleteId);
}
Tomcat 每次都会回答“400 Bad request”,并带有“客户端发送的请求在语法上不正确”的描述。
所以,但是如果我将代理类型更改为 ajax 并将 requestMapping 更改为获取 POST 请求,一切正常。