Spring 无效属性';环境ID';属于bean类。Bean属性';环境ID';不可读或具有无效的getter方法
我正在后端返回模型对象。我正在尝试创建从后端到前端的下拉数据。但我遇到了不可读的异常 这是我的密码Spring 无效属性';环境ID';属于bean类。Bean属性';环境ID';不可读或具有无效的getter方法,spring,jsp,Spring,Jsp,我正在后端返回模型对象。我正在尝试创建从后端到前端的下拉数据。但我遇到了不可读的异常 这是我的密码 public class Customer { private Environments envrironmentId; private Environments environmentName; getters and setters } 这是我的控制器层 @RequestMapping(value="/environments",method = RequestMethod.GET)
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;
}
谁能帮我一下吗?你的字段名为
environmentId
而不是environmentId
。这只是一个类型错误。,。请显示你的getter和setter(并修复你的输入错误,那么错误很可能会消失)。getter的返回类型与setter的参数类型匹配吗?如果您阅读此错误,您将能够理解问题。检查字段environmentId的bean getter方法
<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?