我持有的国家名单(名单),以及持有国家对象的用户对象模型。 我有一个用户可以选择他的国家观点。
这是我的JSP页面的代码片段:
<form:select path="user.country">
<form:option value="-1">Select your country</form:option>
<form:options items="${account.countries}" itemLabel="name" itemValue="id" />
</form:select>
这是我的帐号模式:
public class Account {
private User user;
private List<Country> countries;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public List<Country> getCountries() {
return countries;
}
public void setCountries(List<Country> countries) {
this.countries = countries;
}
}
当JSP负载(GET)的形式:选择显示当前用户国家的选择的项目。 问题是,当我张贴的形式我得到这个异常:
Field error in object 'account' on field 'user.country': rejected value [90];
codes [typeMismatch.account.user.country,typeMismatch.user.country,typeMismatch.country,typeMismatch.org.MyCompany.entities.Country,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [account.user.country,user.country];
arguments []; default message [user.country]];
default message [Failed to convert property value of type 'java.lang.String' to required type 'org.MyCompany.entities.Country' for property 'user.country';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.MyCompany.entities.Country] for property 'country': no matching editors or conversion strategy found]
任何想法如何,我可以解决这个?