Spring MVC模型 - 控制器绑定如何工作

时间:2016-03-14 17:10:31

标签: java spring spring-mvc data-binding

为什么在没有任何注释的示例中,POST处理程序会收到表单的填充实例?

Spring MVC如何确定模型属性与POST方法中的参数之间的绑定?

@RequestMapping( value = "/myurl", method = RequestMethod.GET )
public String setView(Model model) {
    MyClass instance = new MyClass();
    model.addAttribute("viewParameter", instance );
    return TEMPLATE_PATH;
}

@RequestMapping( value = "/myurl", method = RequestMethod.POST)    
public String handleReqest(MyClass instance,  Model model) {
  // Why instance is populated out of the box
}

0 个答案:

没有答案