这是我的表格:
<form:form modelAttribute="fooDTO">
fooCountry:
<form:select path="country">
<form:options items="${countries}" itemLabel="shortName" itemValue="id"/>
</form:select>
Run Code Online (Sandbox Code Playgroud)
这是支持pojo:
public class FooDTO
{
private Country country;
//getters and setters present
}
Run Code Online (Sandbox Code Playgroud)
所选选项默认为fooDTO中的国家/地区值,这很好.但是提交表单时绑定失败了 - 我得到了上述错误,我是否必须在活页夹中注册自定义编辑器,还是有更简单的方法?国家几乎和你期望的一样,国家确实是控制器中填充的国家名单......