can anybody explain me difference between class level controller and method level controller..?
A controller must be marked as @Controller
at the class level. The @RequestMapping
annotation can be applied at both class and method level. If it is, method annotations will be interpreted as relative URLs (relative to the class-level URL). However, method level annotations must be present, otherwise the method won't be mapped.
In annotations, parameters can be marked as optional with default values. The method parameter is such a case: it defaults to GET
, but can be explicitly set to POST
or something else.
See:
@RequestMapping
- 16.3 Implementing Controllers