@ModelAttribute
public void modelAttributeTest1(Model model) {
model.addAttribute("testdata1A", "test String1");
model.addAttribute("testdata1B", "test String2");
}
@ModelAttribute(name="testdata2")
public String modelAttributeTest2() {
return "test String3";
}
@ModelAttribute(value="testdata3")
public Address modelAttributeTest3() {
return new Address("Beijing", "100000");
}
@ModelAttribute
public Address modelAttributeTest4() {
return new Address("Beijing", "100000");
}
@RequestMapping(value="/test5", method=RequestMethod.POST)
public String modelAttributeTest5(@ModelAttribute(value="anAddress") Address anAddress, ModelMap model) {
model.addAttribute("testdata5A", anAddress.getCity());
model.addAttribute("testdata5B", anAddress.getZipCode());
return "modelAttributeTest";
}
@RequestMapping(value="/modelAttributeTest")
@ModelAttribute("testdata6")
public Address modelAttributeTest6() {
return new Address("Hebei", "100003");
}