我有一个 spring mvc 表单
<form:form action="${actionUrl}" method="post" commandName="userAccountVO">
<form:input type="text" path="userName" value="${user.userName}"></input>
//other similar fields
<input type="submit" id="save_changes_button" value="" />
</form:form>
在返回 View 的 Controller 中我有这段代码
model.addAttribute(user, userAccountVO);
model.addAttribute("userAccountVO", new UserAccountVO());
return "view";
但是如果我像这样在输入标记中添加一些值,我会收到上面提到的错误
<form:input type="text" path="userName" value="${user.userName}">some text</input>
此外,如果我尝试提交表单,模型属性对象中的所有字段均为空。
@RequestMapping(value = "/updateuser", method = RequestMethod.POST)
public @ResponseBody
GenericResponse updateUserAccount(
@ModelAttribute("userAccountVO") UserAccountVO userAccountVO,
BindingResult result) {
//userAccountVO here is null, i guess it creates a new object
}
This帖子说这是因为我没有表单支持对象,但我确实有。
可能是什么问题?提前致谢。
最佳答案
明显的建议。替换
<form:input type="text" path="userName" value="${user.userName}"></input>
由
<form:input path="userName"/>
关于java - 错误 : According to TLD, 标记形式 :input must be empty, 但不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16820849/