简体   繁体   English

EL中的PropertyNotFoundException

[英]PropertyNotFoundException in EL

Can some one help me with the exception I have. 有人可以帮我一个例外。

in servlet i send list of countries to jsp 在servlet中,我将国家/地区列表发送到jsp

request.setAttribute("countries", allCountryList);

and in jsp i want to display them in dropdown list , i use foreach to fill the ddl with values 在jsp中,我想在下拉列表中显示它们,我使用foreach将值填充到ddl中

 <c:forEach var="country" items="${requestScope.countries}" >
            <option value="${country.countryNo}">${country.countryName}</option>
  </c:forEach>

Strange exception says that countryName is not exist even it is exist 奇怪的异常说countryName不存在,甚至存在

javax.el.PropertyNotFoundException: Property 'countryName' not found on type ps.iugaza.onlineinfosys.entities.Country

and here is country class 这是乡村课

public class Country {
private String countryName;
private int countryNo;
public String getCoutnryName() {
    return countryName;
}     
public int getCountryNo() {
    return countryNo;
}
}

You have a typo, getCoutnryName() should be getCountryName() . 您有错字, getCoutnryName()应该是getCountryName()

A bit decent IDE can autogenerate getters/setters based on fields. 稍微不错的IDE可以根据字段自动生成getter / setter。 I'd suggest to make use of its powers. 我建议利用它的力量。

Edited: 编辑:

Have you built the project again? 您是否再次构建了该项目? Maybe you add the name attribute and you havent compiled the project again. 也许您添加了name属性,但您尚未再次编译该项目。

The getter should be getCountryName instead of getCoutnryName 吸气剂应该是getCountryName而不是getCoutnryName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM