I've created an application in Spring Rest service for receiving name from Restangular, the application is working fine but I'm getting empty values at the server side, can anyone please tell me some solution for this
Script
Restangular.one('name',"Jhonny").get();
Spring Rest Web Service
@RequestMapping(value = "name/{studentName}", method = RequestMethod.GET, produces = APP_JSON)
@ResponseBody
public void getStudentName(@RequestBody final String studentName)
{
System.out.println("studentName::"+studentName);
}
Output
studentName::
Do this
@RequestMapping(value = "name/{studentName}", method = RequestMethod.GET, produces = APP_JSON)
@ResponseBody
public void getStudentName(@PathVariable("studentName") final String studentName)
{
System.out.println("studentName::"+studentName);
}
The change is to use @PathVariable
to capture the value passed in the URL.
@RequestBody
is used in cases where you want the whole body of the request to be binded to some object (usually the body will be JSON and the binding will the help of Jackson)