spring-mvc Spring-MVC with annotations @Controller & @RequestMapping


public class AppointmentsController {

//your handlers here, for example:

@RequestMapping(path = "/new", method = RequestMethod.GET)
public AppointmentForm getNewForm() {
    return new AppointmentForm();

@RequestMapping(method = RequestMethod.POST)
public String add(@Valid AppointmentForm appointment, BindingResult result) {
    if (result.hasErrors()) {
        return "appointments/new";
    return "redirect:/appointments";


With @Controller annotation you'll mark a Java Class as a Class that holds several HTTP handlers, in other words, HTTP access points to your application.

The @RequestMapping annotation is the one that you'll use to mark HTTP handlers (HTTP access points to your application) within your @Controller Class