我定义了一个 $resource 并添加了一个 PATCH 方法:
myapp.factory( 'Monitoring', function($resource) {
return $resource('/webapp/network/v1/cronjobs/:id/:action', { id: '@id' }, {
status: { method: 'PATCH', params:{id:"@id", action: 'status'}}
}
);
});
调用我得到的 URL 时PATCH http://localhost:8080/webapp/network/v1/cronjobs/1/status 415 (Unsupported Media Type)
changeStatus: function(id, status) {
var m = new Monitoring({id:id});
m.status = status;
m.$status();
}
我的后端是春天
@RequestMapping(value = "/{id}/status", method = RequestMethod.PATCH)
public ResponseEntity<Void> patchStatus(@PathVariable("id") Long id,
@RequestBody String status) {
}