不支持spring + hibernate 405删除方法

时间:2016-11-09 01:42:05

标签: java spring hibernate

当我通过http://localhost:8080/cerebromodel/api/skillChecklists/staff/ {4} / checklist / {1}访问此功能时 我得到405.

//delete custom
    @RequestMapping(value = "/remove/staff/{sid}/checklist/{cid}", method = DELETE, produces = APPLICATION_JSON_VALUE)
    public ResponseEntity<Void> deleteStaffChecklist(@PathVariable Long sid,@PathVariable Long cid) throws URISyntaxException {
        try {
            StaffSkillChecklist ssc = staffSkillChecklistRepository.deleteStaffChecklist(sid, cid);
            staffSkillChecklistRepository.delete(ssc.getId());
            return ResponseEntity.ok().build();
        } catch (Exception x) {
            // todo: dig exception, most likely org.hibernate.exception.ConstraintViolationException
            return ResponseEntity.status(HttpStatus.CONFLICT).build();
        }
    }

缺少什么?

1 个答案:

答案 0 :(得分:1)

您的访问链接为http://localhost:8080/cerebromodel/api/skillChecklists/staff/{4}/checklist/{1}

虽然处理程序将URL称为

/remove/staff/{sid}/checklist/{cid}

在您的访问链接中缺少删除