我是按照一个教程,我得到了这个错误
Neither BindingResult nor plain target object for bean name 'command' available as request attribute
这是我正在使用的代码。
<form:form action="saveCustomer" ModelAttribute="customer" method="POST">
<table>
<tbody>
<tr>
<td><label>First name:</label></td>
<td><form:input path="firstName"/></td>
</tr>
<tr>
<td><label>Last name:</label></td>
<td><form:input path="lastName"/></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td><form:input path="email"/></td>
</tr>
</tbody>
</table>
</form:form>
这是客户窗体,添加新客户时,问题发生在
名字输入
显示窗体的get方法是:
@GetMapping("/showFormForAdd")
public String showFormForAdd(Model theModel) {
Customer theCustomer = new Customer();
theModel.addAttribute("customer", theCustomer);
return "customer-form";
}
客户实体为:
@Column(name="first_name")
private String firstName;
@Column(name="last_name")
private String lastName;
@Column(name="email")
private String email;
bean名称“command”
因此,我将属性的名称改为command,它工作了,但是如果使用customer,为什么它不工作呢。
在教程中,他没有使用命令。