Spring给我们提供了一个commandName属性,我们可以通过该属性来指定我们将使用Model中的哪个属性作为form需要绑定的command对象。<form:form id="inputForm" commandName="matUse" action="${ctx}/mat/matUse/save" method="post" class="form-horizontal">除了commandName属性外,指定modelAttribute属性也可以达到相同的效果。<form:form id="inputForm" modelAttribute="matUse" action="${ctx}/mat/matUse/save" method="post" class="form-horizontal">报这个错误的原因是 在全局替换 bean字段 model 为module 的时候把 modelAttribute 替换成了 moduleAttribute 。导致Spring mvc 找不到对应的绑定对象了
Neither BindingResult nor plain target object for bean name 'command' availa
最新推荐文章于 2020-08-18 15:39:46 发布
本文介绍了Spring MVC中form表单绑定的两种方式:commandName和modelAttribute属性,并通过实例展示了如何使用这些属性来指定要绑定的Model对象。此外,还讨论了一个常见错误,即误将modelAttribute写为moduleAttribute时Spring MVC无法找到正确的绑定对象。
1万+

被折叠的 条评论
为什么被折叠?



