Follow this :
@RequestMapping(value = {"/abcd/id={id}","/abcd?id={id}"}, method = RequestMethod.GET)
public ModelAndView test(@PathVariable("id") String id) {
I have specified two type of values above in my code. former works fine when we call the uri but later is not getting identified (i.e.) @RequestMapping
is not identifying ?(question mark)
as part of parameter passed.
You should get params on URL using @RequestParam
as a method parameter.
@RequestMapping(value = "/abcd", method = RequestMethod.GET)
public void test(@RequestParam String id) {
// your code here
}
Question mark in urls (and uris) is used to separate parameters from the path.
@RequestMapping
takes a path as it's value
attribute. Hence it shouldn't contain question marks.
So basically your first case is interpreted as a path (although a strange one) and the second one is simply wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With