Posts

Showing posts with the label @RequestMapping

Spring @RequestMapping Annotation Example

Image
In this section we will learn about @RequestMapping  Annotation.   @RequestMapping  is used to map web requests onto specific handler classes and/or handler methods.  @RequestMapping  can be applied to the controller class as well as methods. It has the following optional options name : Assign a name to this mapping. value :  The primary mapping expressed by this annotation. method : The HTTP request methods to map to headers : The headers of the mapped request, narrowing the primary mapping. @Controller @RequestMapping ( "/employees" ) public class EmployeeController { @RequestMapping ( "/employee" ) public String getEmployee ( ) { } } A  @RequestMapping  on the class level is not required. Without it, all paths are simply absolute, and not relative. This means if you specify the class level annotations, the URL shall be relative, it shall be  http://localhost:8080/employees/employee (URL to Handler mapping) and likewi...