@RequestMapping(value = {\"/abcd\", \"/employees/{value}/{id}\"})
public String getEmployees(
@PathVariable(value = \"value\") String val,
@PathVariable(val
We can't have optional path variables
, you can have two controller methods which can call the same service.
First Method
@RequestMapping("/abcd")
public String getEmployees(@RequestParam(value="param", required=false)String value){}
Second Method
@RequestMapping("/employees/{value}/{id}")
public String getEmployees(@PathVariable(value="value") String val, @PathVariable(value="id") String id, @RequestParam(value="param", required=false) String value){}
For @RequestParam
we can use,
@RequestParam(value="somevalue",required=false)
for optional params
rather than a pathVariable