Spring-Bootで文字列値を渡す方法@RequestMapping("/test")
。Springブート@requestMappingに設定された/動的なURLを渡す方法を教えてください。
String str ="/test"
を文字列の値としてRequestMapping(str)
に渡したい場合は、リクエストマッピングの文字列値を読み取る方法をお勧めします。
Spring-Bootで文字列値を渡す方法@RequestMapping("/test")
。Springブート@requestMappingに設定された/動的なURLを渡す方法を教えてください。
String str ="/test"
を文字列の値としてRequestMapping(str)
に渡したい場合は、リクエストマッピングの文字列値を読み取る方法をお勧めします。
あなたが使用することができ、主に2 opions:
オプション1:あなたはこのようにリクエストを構築する必要があり
@RequestMapping("/{pathVariable}/yourUrl")
public void yourRequestMethod(@PathVariable("pathVariable")String pathVariable){...}
そして:
/yourValue/yourUrl
オプション2:
@RequestMapping("/yourUrl")
public void yourRequestMethod(@RequestParam("test")String test){...}
そして、あなたはLD、このような要求を構築:
/yourUrl?test=yourValue
これは @RequestMapping("${test.str.value}")
を動作するはずですし、あなたのapplication.proprties/yml
test.str.value = /test
にあなたは応答を検証することができますか?ありがとうございました! – cralfaro