can anybody explain me difference between class level controller and method level controller..?
annotations, java, spring, spring-annotations, spring-mvc
Solution
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
Problem
I am new to spring framework....while searching on google..I found few examples which has @RequestMapping annoted at the class level and few examples showing it at menthod level When to use class level RequestMapping and menthod level RequestMapping annotation...can anybody explain me difference between class level RequestMapping and method level RequestMapping ..?? so I am little bit confused about their application at : a) Class level b) Method level Also I found some `@Requestmapping` with type :GET/Post,whereas some examples doesn't have type parameter. Which approach is better ..?? Is newer versions(>Spring 2.5) don't need parameter type for request mapping ???