我是spring mvc框架的新手-我遇到了一个类似的问题-
有课
class User{
private String name;
private City city;
//getters setters
}
class Country{
private int id;
private String name;
//getters setters
}
class State{
private int id;
private String name;
private Country country;
//getters setters
}
class city{
private int id;
private String name;
private State state;
State state;
//getters setters
}
我有这样的表格
<form:form modelAttribute="user" method="POST">
<form:label path="name">Name</form:label>
<form:input path="name"/>
<form:label path="city.state.country">Country</form:label> //Getting error here
<form:select path="city.state.country"></form:select>
<form:label path="city.state"></form:label>
<form:select path="city.state"></form:select>
<form:label path="city"></form:label>
<form:select path="city"></form:select>
</formform>
错误
org.springframework.beans.NotReadablePropertyException: Invalid property 'city.state' of bean class [org.opentutor.beans.User]: Bean property 'city.state' is not readable or has an invalid getter method:
getter 的返回类型是否与 setter 的参数类型匹配?
基本上我很困惑如何设置用户的国家、州和城市值。