@ModelAttributeSpring MVC 的目的和用途是什么?
我有
Class Shape {
//Implementation
}
Class Round extends Shape{
//Implementation
}
Run Code Online (Sandbox Code Playgroud)
控制器我有
@Requestmapping(value="/view/form")
public ModelAndView getForm(){
ModelAndView mav=new ModelAndView();
mav.addObject("shape",new Round());
}
@RequestMapping(value="/submit", method = RequestMethod.POST)
public ModelAndView submitForm(@ModelAttribute("shape") Shape shape){
if(shape instanceof Round){ //**Not giving positive result**
}
}
Run Code Online (Sandbox Code Playgroud)
在Jsp
<form:form action="/submit" commandName="shape" method="post">
//form tags
</form:form>
Run Code Online (Sandbox Code Playgroud)
当我用Round对象提交表单时.在控制器端,ModelAttribute没有给出Round的实例.它只给出形状的例子.这该怎么做