控制器 RequestMapping

@Controller
@RequestMapping("/appointments")
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";
    }
    appointmentBook.addAppointment(appointment);
    return "redirect:/appointments";
}

}

使用 @Controller 注释,你可以将 Java 类标记为包含多个 HTTP 处理程序的类,换句话说,是应用程序的 HTTP 访问点。

@RequestMapping 注释是用于在 @Controller 类中标记 HTTP 处理程序(应用程序的 HTTP 访问点)的注释