【发布时间】:2015-06-16 03:00:36
【问题描述】:
在学习Spring MVC知识的过程中,有一些关于Spring返回类型的东西让我很困惑。
在本文档中: Mapping Requests With @RequestMapping 他们返回 appointments/new 和 redirect:/appointments。
代码
@RequestMapping(method = RequestMethod.POST)
public String add(@Valid AppointmentForm appointment, BindingResult result) {
if (result.hasErrors()) {
return "appointments/new";
}
appointmentBook.addAppointment(appointment);
return "redirect:/appointments";
}
这两种返回类型的主要区别是什么?据我了解,第一种类型作为前向操作返回,但如果我是对的,为什么他们还将forward:/ 作为返回类型发布?
【问题讨论】:
标签: java spring spring-mvc model-view-controller