生成的实体报告DELETE不起作用

时间:2014-05-04 00:50:17

标签: java spring angularjs jhipster

我在MacOSX Maverick上使用JHipster 0.13和JDK 1.7.0.55。到目前为止一切正常。

我的问题是我已经生成了一个新实体,并且可以在经过一些修改后添加新实体。但是当我点击删除按钮时,前端没有任何反应。在我的Chrome控制台中 DELETE http://0.0.0.0:9000/app/rest/products?productId=1 405 (Method Not Allowed) angular.js:8081 XHR finished loading: DELETE "http://0.0.0.0:9000/app/rest/products?productId=1".

后端记录消息: [WARN] org.springframework.web.servlet.PageNotFound - Request method 'DELETE' not supported

删除方法已由生成器定义,据我所知,它应该可以工作。

我需要检查/修改任何其他地方才能使其正常工作?

在AngularJS中定义了这个service.js:

myapp.factory('Product', ['$resource', function ($resource) { return $resource('app/rest/products/:id', {}, { 'query': { method: 'GET', isArray: true}, 'get': { method: 'GET'}, 'delete': {method: 'DELETE'} }); }]);

在Java方面,我有:

/** * DELETE /rest/products/:id -> delete the "id" product. */ @RequestMapping(value = "/rest/products/{id}", method = RequestMethod.DELETE, produces = "application/json") @Timed public void delete(@PathVariable Long id, HttpServletResponse response) { log.debug("REST request to delete Product : {}", id); productRepository.delete(id); }

这是在具有添加和保存方法的同一个类中,这是有效的。

1 个答案:

答案 0 :(得分:0)

发现我的错误。使用重构在视图中重命名错误的参数。未提交ID,并且与/ delete / {id}的REST映射不匹配。