0

In Jersey Rest API

if any common request parameters are there then we can capture that value at RootResource level using the below code.

@QueryParam("q")
private String qQueryParams

Is there any similar approach in Spring Rest API.

In other words, all my endpoint URL will contain the query parameter "q". How to capture this data at class level instead of every request.

Thanks, Vijay

Vijay
  • 41
  • 7
  • see https://stackoverflow.com/questions/62957700/using-a-string-variable-in-requestmapping-value/62957795#62957795 – J Asgarov Jul 18 '20 at 22:51

1 Answers1

0

you can use @RequestMapping({q}/test) above controller and pass @PathVariable String q as method argument.

@Controller
@RequestMapping(value = "{q}/test")
class TestController {

    @RequestMapping(value="/abc")
    public ModelAndView doSomething(@PathVariable String q) {
       // do something with q...
    }

}