EL 中的 PropertyNotFoundException
有人可以帮助我解决我遇到的例外情况吗?
在 servlet 中,我将国家/地区列表发送到 jsp
request.setAttribute("countries", allCountryList);
,在 jsp 中,我想在下拉列表中显示它们,我使用 foreach
用值填充 ddl
<c:forEach var="country" items="${requestScope.countries}" >
<option value="${country.countryNo}">${country.countryName}</option>
</c:forEach>
奇怪的异常表明,countryName 不存在,即使它存在,
javax.el.PropertyNotFoundException: Property 'countryName' not found on type ps.iugaza.onlineinfosys.entities.Country
并且这是乡村班
public class Country {
private String countryName;
private int countryNo;
public String getCoutnryName() {
return countryName;
}
public int getCountryNo() {
return countryNo;
}
}
Can some 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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有一个拼写错误,
getCoutnryName()
应该是getCountryName()
。一个像样的 IDE 可以根据字段自动生成 getter/setter。我建议利用它的力量。
You have a typo,
getCoutnryName()
should begetCountryName()
.A bit decent IDE can autogenerate getters/setters based on fields. I'd suggest to make use of its powers.
编辑:
您再次构建了该项目吗?也许你添加了name属性,但你还没有再次编译项目。
getter 应该是 getCountryName 而不是 getCoutnryName
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