我开始学习Spring Boot,并试图提供一个简单的REST服务以对员工记录实施CRUD操作。但是执行DELETE方法时出现此错误-
{ “ timestamp”:“ 2018-08-10T11:17:47.619 + 0000”, “状态”:405, “错误”:“方法不允许”, “ message”:“不支持请求方法“ DELETE””, “路径”:“ / employees / 123” }
我的控制器-
@DeleteMapping("/employee/{id}")
public String deleteEmployee(@PathVariable int id) {
return employeeService.deleteEmployee(id);
}
我的服务-
public String deleteEmployee(int id) {
// TODO Auto-generated method stub
for(int i=0;i<list.size();i++) {
if(list.get(i).getId()==id) {
list.remove(i);
}
}
return "Employee withh id "+id+" has been removed from the company";
}
答案 0 :(得分:6)
在您粘贴的输出中,路径为<div class="popup" v-if="popupIndex === index">Delete</div>
,与您的/employees/123
不匹配。