长话短说,使用Java bean约定将path属性绑定到Java属性中。例如以下形式:
<form:form method="post" modelAttribute="theStudent"> Name: <form:input type="text" path="name"/> Cool?: <form:input type"checkbox" path="cool"/> <button>Save</button></form:form>
以及以下控制器处理程序方法:
@RequestMapping(...)public String updateStudent(@ModelAttribute("theStudent") Student student) { // ...}如果使用以下属性定义了Student类,则将自动绑定:
public class Student { private String name; public String getName() { return this.name; } public void setName(String name) { this.name = name; } private boolean cool; public boolean isCool() { return this.cool; } public void setCool(boolean cool) { this.cool = cool; }}规范文档的第8.3节提供了有关JavaBeans对流的更多信息。



