Getting null with @pathparam and @requestmapping

I use spring-boot 1.4.3.RELEASE to create web services, whereas by asking with help http://localhost:7211/person/get/ramI get null for id property

@RequestMapping(value="/person/get/{id}", method=RequestMethod.GET, produces="application/json")
    public @ResponseBody Person getPersonById(@PathParam("id") String id) {
        return personService.getPersonById(id);
    }

Could you suggest me if there is something that I missed.

+4
source share
2 answers

Annotations for getting the @PathVariable path variable . It looks like you used @PathParam, which is not true.

Check this out for more details:

requestparam-vs-pathvariable

+13
source

idshould be Longinstead of Stringc @PathVariable. If yes, then...

@RequestMapping(value="/person/get/{id}", method=RequestMethod.GET, produces="application/json")
public @ResponseBody Person getPersonById(@PathVariable("id") Long id) {
    return personService.getPersonById(id);
}
0
source

Source: https://habr.com/ru/post/1666817/


All Articles