I am confused with behavior @RequestParam(value="someValue"). The docs say that
When using controller interfaces (for example, to proxy AOP), be sure to sequentially put all your mapping annotations, such as @RequestMapping and @SessionAttributes, on the controller interface, and not on the implementation class.
If I put @RequestParama controller in my interface, it is valuecompletely ignored (and therefore the displayed value is equal nullif the parameter name is different from the name of the received parameter), but defaultValueit requiredworks ok.
If I put @RequestParama controller in my implementation, everything works fine.
I read this answer, but I cannot understand why some parameters work and others not, and why docs are wrong.
Code example:
interface:
@RequestMapping(method = RequestMethod.GET)
List<MyObject> get(
//works if parameter in request has name "userName", which is not correct
@RequestParam(value = "username", required = false) String userName,
@RequestParam(value = "searchValue", required = false) String searchValue,
@RequestParam(value = "someId", required = false) Integer someId);
implementation:
@Override
public List<MyObject> get(
String userName,
String searchValue,
Integer someId) {
return myService.get(userName, searchValue, someId);
}
source
share