【发布时间】:2019-09-27 15:38:44
【问题描述】:
如何按 ID 搜索字符串 Pathvariable 而不是 Integer?我喜欢找名字。
下面的方法效果很好,但只是将 ID 用作整数值。
谢谢:)
@RestController
@RequestMapping(value = "/etbestandservice")
public class ETBestandserviceController {
@Autowired
ETBestandserviceRepository etbestandRepos;
@GetMapping(value = "/find/{id}", produces = "application/json")
public Optional<ETBestandservice> findErsatzteile(@PathVariable("id") Integer id, ETBestandservice et) {
id = et.getId();
return etbestandRepos.findById(id);
}
}
【问题讨论】:
-
能否请您稍微澄清一下您的问题?
标签: java mysql spring-data-jpa findby