日期:2014-05-20 浏览次数:20942 次
@Controller
public class ContactController {
@RequestMapping(value = "/addContact", method = RequestMethod.POST)
public String addContact(@ModelAttribute("contact") Contact contact, BindingResult result) {
// @ModelAttribute will binds the data from request to the object
// Contact.
System.out.printf("Name: %s, Mail: %s\n", contact.getName(), contact.getMail());
return "redirect:contacts.htm"; // 看这里
}
@RequestMapping("/contacts")
public ModelAndView showContacts() {
return new ModelAndView("contact", "command", new Contact());
}
}