
modelAttribute="<Model Name"。
例:
@Controller@RequestMapping("/greeting.html")public class GreetingController { @ModelAttribute("greeting") public Greeting getGreetingObject() { return new Greeting(); } @RequestMapping(method = RequestMethod.GET) public String handleRequest() { return "greeting"; } @RequestMapping(method = RequestMethod.POST) public ModelAndView processSubmit(@ModelAttribute("greeting") Greeting greeting, BindingResult result){ ModelAndView mv = new ModelAndView(); mv.addObject("greeting", greeting); return mv; }}在你的JSP中:
<form:form modelAttribute="greeting" method="POST" action="greeting.html">
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)