I want to use the form:options provided by Spring to provide choices.
My JSP implemented with Spring 2.5 is
<td><form:select path="billingType">
<form:options items="${addAccountCommand.billingTypeChoice}" itemValue="billingType" itemLabel="billingTypeName" />
</form:select>
</td>
My AccountCommand.java is
private int billingType;
private String billingTypeName;
public int getBillingType() {
return billingType;
}
public void setBillingType(int billingType) {
this.billingType = billingType;
}
private Map<String, Integer> billingTypeChoice = new HashMap<String, Integer>() {
{
put("Monthly", 1);
put("Block", 2);
put("Per Use", 3);
}
};
public Map<String, Integer> getbillingTypeChoice() {
return billingTypeChoice;
}
public void setbillingTypeChoice(Map<String, Integer> billingTypeChoice) {
this.billingTypeChoice = billingTypeChoice;
}
public String getBillingTypeName() {
return billingTypeName;
}
public void setBillingTypeName(String billingTypeName) {
this.billingTypeName = billingTypeName;
}
My Eclipse console is:
15:55:23,140 ERROR org.springframework.web.servlet.tags.form.OptionsTag:84 - Invalid property 'billingType' of bean class [java.lang.String]: Bean property 'billingType' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.NotReadablePropertyException: Invalid property 'billingType' of bean class [java.lang.String]: Bean property 'billingType' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:540)
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:532)
at org.springframework.web.servlet.tags.form.OptionWriter.renderFromMap(OptionWriter.java:164)
...