我在后端返回模型对象。我正在尝试从后端到前端创建下拉数据。但是我得到了不可读的异常..
这是我的代码......
public class Customer {
private Environments envrironmentId;
private Environments environmentName;
getters and setters
}
这是我的控制器层。
@RequestMapping(value="/environments",method = RequestMethod.GET)
public ModelAndView getenvironments(HttpServletRequest request,
HttpServletResponse response,@ModelAttribute("customer") Customer customer,@RequestParam String selectedcustomername) throws Exception{
System.out.println("selected cust name"+selectedcustomername);
ModelAndView model = null;
Map<String, Object> map = new HashMap<String, Object>();
List<org.mvc.domain.Environments> environmentNames = loginDelegate.getEnvironments(selectedcustomername);
Collections.sort(environmentNames, new CustomComparator());
for(int i=0;i<environmentNames.size()-1;i++){
customer.setEnvrironmentId(environmentNames.get(0));
customer.setEnvironmentName(environmentNames.get(1));
}
map.put("environmentNames", environmentNames);
model = new ModelAndView("welcome", "map", map);
return model;
}
这是我的Ui ..
<form:form method="get" action="retrieve" modelAttribute="customer" commandName="customer">
<b>Environment:</b>
<form:select path="environmentId" id="environmentDetails">
<option selected="selected">Select An Environment</option>
<form:options items="${map.environmentNamesList}" itemLabel="environmentName" itemValue="environmentId"/>
</form:select>
</td>
这是我的错误..
org.apache.jasper.JasperException: org.springframework.beans.NotReadablePropertyException: Invalid property 'environmentId' of bean class [org.mvc.domain.Customer]: Bean property 'environmentId' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
任何人都可以帮助我