私は次のコントローラを持っているとしましょう。フィールドに@PathVariableを挿入するにはどうすればよいですか?
@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) {
}
}
ここで、フィールドにpath
を注入します。
// 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
}
コンパイルされません。
どうすればいいですか?
いいえ、 '@ PathVariable'を行うことができない、その理由あなたは これをしたいですか? – Blank
目的は何ですか? –