I have a Controller with RequestMapping(foo/{fooId}/bar/})
, FooEntity
is used in all methods, how can i preload FooEntity
for all the methods of FooController
?
@RestController
@RequestMapping("foo/{fooId}/bar")
public class FooController {
public void prefetchFoo(@PathVariable Long fooId) {
...
}
@PostMapping("/")
public ResponseEntity<void> createFooBar(FooEntity prefetchedFoo) {
...
}
@GetMapping("/{barId}")
public ResponseEntity<void> getFooBar(FooEntity prefetchedFoo) {
...
}
}
I have found @ModelAttribute
in my research, but i only saw it in the context of web views, is it viable to use it in the context of JSON APIs?