extjs asfrontend と Spring as backend に基づいて小さなアプリケーションを構成しようとしています。したがって、extjs からサーバーと通信するには、ストアでプロキシ ライターを構成する必要があります。私のプロキシ構成は次のようになります。
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 リクエストの取得に変更すると、すべて正常に動作します。