开发者

PropertyNotFoundException in EL

Can s开发者_运维知识库ome one help me with the exception I have.

in servlet i send list of countries to 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

 <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

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().

A bit decent IDE can autogenerate getters/setters based on fields. 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.

The getter should be getCountryName instead of getCoutnryName

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜