Spring @Deletemapping:无法解析占位符“ id”的值

时间:2019-09-20 17:35:12

标签: spring rest

我很确定响应已在网站上,但找不到。我的@RestControler中的代码错误是什么?

@DeleteMapping("/deleteById/${id}")
public void deleteById(@PathVariable("id") Long id) {
    this.customerServiceImpl.deleteById(id);
}

错误:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'id' in value "/deleteById/${id}"

1 个答案:

答案 0 :(得分:1)

您可以尝试使用。它应该工作。

@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable(name="id") Long id) {
    this.customerServiceImpl.deleteById(id);
}