枚举定义为:
public enum Country {
US("United States"),
CA("Canada"),
AUS("Australia");
private String fullName;
private Country(String fullName) {
this.fullName = fullName;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
}
模型是:
public class Workspace implements Serializable {
// ...
@Valid
@NotNull
private Address address;
//...
}
public class Address implements Serializable {
// ...
private Country country;
//...
}
我有一个这样的视图对象:
public class WorkspaceVO implements Serializable {
//..
private Workspace workspace;
//...
}
最后在我的jsp中我想做:
<form:select id="country" path="workspace.address.country">
<form:options items="${workspace.address.country}" itemLabel="fullName"/>
</form:select>
我在我的代码的其他位置重复了这种确切的情况,并且工作正常。我没有看到任何区别,但是,当我访问 jsp 时出现错误...
javax.servlet.jsp.JspException:类型 [com.mycompany.web.Country] 对选项项无效
任何想法为什么?