How to pass String value in Spring-Boot @RequestMapping("/test").
I want to pass String str ="/test" as String value in RequestMapping(str), please suggest how to read String value in Request Mapping.
How to pass String value in Spring-Boot @RequestMapping("/test").
I want to pass String str ="/test" as String value in RequestMapping(str), please suggest how to read String value in Request Mapping.
You can use mainly 2 opions:
Option 1:
@RequestMapping("/{pathVariable}/yourUrl")
public void yourRequestMethod(@PathVariable("pathVariable")String pathVariable){...}
And you should build the request like this:
/yourValue/yourUrl
Option 2:
@RequestMapping("/yourUrl")
public void yourRequestMethod(@RequestParam("test")String test){...}
And you should build the request like this:
/yourUrl?test=yourValue