BeanResult的BindingResult和普通目标对象都不能作为请求attr使用

BeanResult的BindingResult和普通目标对象都不能作为请求attr使用,第1张

BeanResult的BindingResult和普通目标对象都不能作为请求attr使用

确保你的Spring表单提及

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">


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5037335.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-15
下一篇2022-11-15

发表评论

登录后才能评论

评论列表(0条)

    保存