我在Spring-RS中获得了一些REST端点,它使用实体id作为路径变量。大多数情况下,该方法要做的第一件事就是使用id检索实体。有没有一种方法可以自动将id映射到实体,只将实体作为方法参数?
现状:
@RequestMapping(path="/{entityId})
public void method(@PathVariable String entityId) {
Entity entity = entityRepository.findOne(entityId);
//Do some work
}我想要的是:
@RequestMapping(path="/{entityId})
public void method(@PathVariable Entity entityId) {
//Do some work
}https://stackoverflow.com/questions/41240096
复制相似问题