Let's say I have following controller.
@RestController()
@RequestMapping("/my/{path}")
public class MyController {
public void some1(@PathVariable("path") String path) {
}
public void some2(@PathVariable("path") String path) {
}
public void some3(@PathVariable("path") String path) {
}
}
Now I want the path
be injected into a field.
// I usually do this with JAX-RS
@RequestScope // I added this!
@RestController()
@RequestMapping("/my/{path}")
public class MyController {
public void some1() {
}
public void some2() {
}
public void some3() {
}
// single declaration for all methods
// I know ElementType.FIELD is not one of @PathVariable's target
// Is there any equivalent way to do this with Spring?
@PathVariable("path")
String path
}
Not compiles.
How can I do this?