javax.el.PropertyNotFoundException:在类型上找不到属性“名称" [英] javax.el.PropertyNotFoundException: Property 'Name' not found on type

查看:1144
本文介绍了javax.el.PropertyNotFoundException:在类型上找不到属性“名称"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下代码:

FriendsList = new ArrayList()
....   
ResultSet rs = st.executeQuery(Select);
while (rs.next()) {
   Member member = new Member(rs);
   FriendsList.add(member);
}

它成功获取结果,并转到Member类的构造函数并向其中添加数据.但是一旦我尝试使用jsp文件中的FriendsList属性访问其属性之一,就会遇到以下错误:

it successfully get the results and goes to constructor of Member class and add data to it. but once I try to access one of its properties using FriendsList property from my jsp file I run into following error:

 "Caused by: javax.el.PropertyNotFoundException: Property 'Name' not found on type   
 application.Member"

使用Eclipse,我为Member类的每个属性生成了一个setter和getter的完整列表,如下所示:

Using Eclipse I have generated a completed list of setters and getters for every property of Member class as following:

    public String getName() {
    return Name;
}
public void setName(String name) {
    Name = name;
}

推荐答案

关键是将属性名称"转换为方法名称.通常,通过使用属性名称,将第一个字符大写并在"get"之前添加获取名称.

The key is the conversion of "property name" to the method name. In general the getter name is obtained by taking the property name, uppercasing the first character and prepending "get".

因此,如果要调用getName方法,则该属性为名称",并带有小写的n,而不是大写的N.

So if you want to call the getName method the property is "name" with a lowercase n, not an uppercase N.

对于属性,实际上也有很多特殊情况,它们实际上都是以大写字母开头,但是如果您进行设置,则生活会更加简单,因此属性名称始终以小写字母开头.

There are also many many special cases for properties that actually do start with uppercase letters and the like, but life is much simpler if you set it up so your property names always start with lower case letters.

这篇关于javax.el.PropertyNotFoundException:在类型上找不到属性“名称"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆