Examples without @RequestParam
Based on the list of
HandlerMethodArgumentResolver configured in your application,
@RequestParam can also be omitted. If you have a look at the code of
method getDefaultArgumentResolvers() of RequestMappingHandlerAdapter
there is the following piece of code at the end:
// Catch-all resolvers.add(new
RequestParamMethodArgumentResolver(getBeanFactory(), true));
resolvers.add(new ServletModelAttributeMethodProcessor(true));
// Catch-all resolvers.add(new
RequestParamMethodArgumentResolver(getBeanFactory(), true));
resolvers.add(new ServletModelAttributeMethodProcessor(true));
Basically, it’s added to the resolvers a
RequestParamMethodArgumentResolver with useDefaultResolution set to
true. Looking at the documentation we can see that this means that
method argument that is a simple type, as defined in
BeanUtils.isSimpleProperty(java.lang.Class), is treated as a
request parameter even if it isn’t annotated. The request parameter
name is derived from the method parameter name.