11. Spring MVC @RequestMapping
Spring MVC @RequestMapping In spring MVC @RequestMapping plays the role of mapping URL to the method of controller class. In Spring MVC application we generally use a URL which calls the Controller. In the Controller to map a given URL we use @RequestMapping annotation. RequestMapping can be used in many ways. 1. RequestMapping at Class Level 2. RequestMapping only at Method level 3. @RequestMapping annotations at class level as well as method levels 4. RequestMapping using HTTP methods 5. @RequestMapping with @RequestParam 6. @RequestMapping with @PathVariable 1. RequestMapping at Class Level @RequestMapping can be added at class Level. This way the URI provided will act as base URI for all other methods in the Controller class. @Controller @RequestMapping(value = "/employee") public class EmployeeController { // Methods.... } Now any requests with /employee as URL will hit this Controller class. 2. RequestMapping only at Method level @RequestMapping is optional for class ...