Spring Boot如何在@requestMapping中传递配置/动态url?
如何在Spring Boot中传递字符串值Spring Boot如何在@requestMapping中传递配置/动态url?,spring,spring-boot,Spring,Spring Boot,如何在Spring Boot中传递字符串值@RequestMapping(“/test”) 我想通过String str=“/test”作为RequestMapping(str)中的字符串值,请建议如何读取请求映射中的字符串值。您可以主要使用两种观点: 备选案文1: @RequestMapping("/{pathVariable}/yourUrl") public void yourRequestMethod(@PathVariable("pathVariable")String pathVar
@RequestMapping(“/test”)
我想通过
String str=“/test”
作为RequestMapping(str)
中的字符串值,请建议如何读取请求映射中的字符串值。您可以主要使用两种观点:
备选案文1:
@RequestMapping("/{pathVariable}/yourUrl")
public void yourRequestMethod(@PathVariable("pathVariable")String pathVariable){...}
您应该像这样构建请求:
/yourValue/yourUrl
/yourUrl?test=yourValue
备选案文2:
@RequestMapping("/yourUrl")
public void yourRequestMethod(@RequestParam("test")String test){...}
您应该像这样构建请求:
/yourValue/yourUrl
/yourUrl?test=yourValue
这应该行得通
@RequestMapping(“${test.str.value}”)
和您的应用程序.properties/yml
test.str.value=/test
您能验证响应吗?可能对其他成员有用,谢谢!