I am trying to build RESTful web service by using spring 4.0
I have a controller:
@Controller
@RequestMapping("test")
public class Controller{
@RequestMapping("fetch",method=RequestMethod.GET)
@ResponseStatus(value=HttpStatus.OK)
@ResponseBody
public ResultResponse fetchController(ResultRequest req){
if((req.getName).equals("John"))
return new ResultResponse(100);
else
return new ResultResponse(0);
}
}
and my ResultRequest.class
public class ResultRequest{
private String name;
//getter,setter
}
If I hit the url to //host//contextPath/test/fetch?name=John
the controller will return the object ResultResponse(100)
my question is, there no @RequestParam or other annotation in the request parameter, how does the spring controller know to set the query parameter "name" as the property of wrapper class ResultRequest ?
Thanks