javax.el.PropertyNotFoundException,为什么xAxis和getXAxis不匹配
javax.el.PropertyNotFoundException, why does xAxis not match with getXAxis
EL 2.2 在 Tomcat 7 投掷中
javax.el.PropertyNotFoundException: Property 'xAxis' not found on type ...
当我尝试访问以下内容时 属性
private XAxis xAxis;
public XAxis getXAxis() {
return xAxis;
}
像这样
${bean.xAxis}
在 JSP.
根据我对 JavaBeans 和 EL 规范的理解,getXAxis
是 xAxis
属性 的正确访问器。 Lombok 同意我的看法,它也生成一个 getXAxis
方法。然而,Eclipse 中的 "Getter and Setter" 生成器不同意,因为它生成 getxAxis
.
更新
同时我发现了一些事情:
- 这个案例有一个 'won't fix' issue for Lombok
- 所有 3 个主要的 IDE 似乎都生成
getxAxis
- 有一个 nice blog post dedicated to this corner case, it's referenced in 并引用了 Java Beans 规范的第 8.8 章
仍然,我无法理解 Java Beans 规范的第 8.8 章如何适用于此,因为它描述了不同的情况。对我来说,这看起来更像是 java.beans.Introspector#decapitalize
的实现细节,而不是明确定义的行为。
public static String decapitalize(String name) {
if (name == null || name.length() == 0) {
return name;
}
if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
Character.isUpperCase(name.charAt(0))){
return name;
}
char chars[] = name.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return new String(chars);
}
规范说
Thus when we extract a property or event name from the middle of an
existing Java name, we normally convert the first character to lower
case. However to support the occasional use of all upper-case names,
we check if the first two characters of the name are both upper case
and if so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
但是"if the first two characters of the name are both upper case"在这里不适用。
我错过了什么?
The spec says
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to
lower case. However to support the occasional use of all upper-case
names, we check if the first two characters of the name are both upper
case and if so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
但是"if the first two characters of the name are both upper case"
不适用于此处。
我错过了什么?
您的方法的“现有Java名称”是"getXAxis",或者对于布尔值[=37],它可能是"isXAxis" =].
“现有 Java 名称 的 中间是 "XAxis"。其中的 "first two characters" 是 "XA",所以它保持原样,没有资本化。
有一种方法可以将方法名称显式映射到具有显式 BeanInfo 的 属性 名称,但很少使用。
顺便说一句,JavaBeans 1.01 规范的日期是 1997 年 8 月。它被积极使用了 18 年。下载页面:
http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html
EL 2.2 在 Tomcat 7 投掷中
javax.el.PropertyNotFoundException: Property 'xAxis' not found on type ...
当我尝试访问以下内容时 属性
private XAxis xAxis;
public XAxis getXAxis() {
return xAxis;
}
像这样
${bean.xAxis}
在 JSP.
根据我对 JavaBeans 和 EL 规范的理解,getXAxis
是 xAxis
属性 的正确访问器。 Lombok 同意我的看法,它也生成一个 getXAxis
方法。然而,Eclipse 中的 "Getter and Setter" 生成器不同意,因为它生成 getxAxis
.
更新
同时我发现了一些事情:
- 这个案例有一个 'won't fix' issue for Lombok
- 所有 3 个主要的 IDE 似乎都生成
getxAxis
- 有一个 nice blog post dedicated to this corner case, it's referenced in 并引用了 Java Beans 规范的第 8.8 章
仍然,我无法理解 Java Beans 规范的第 8.8 章如何适用于此,因为它描述了不同的情况。对我来说,这看起来更像是 java.beans.Introspector#decapitalize
的实现细节,而不是明确定义的行为。
public static String decapitalize(String name) {
if (name == null || name.length() == 0) {
return name;
}
if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
Character.isUpperCase(name.charAt(0))){
return name;
}
char chars[] = name.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return new String(chars);
}
规范说
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
但是"if the first two characters of the name are both upper case"在这里不适用。
我错过了什么?
The spec says
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
但是"if the first two characters of the name are both upper case" 不适用于此处。
我错过了什么?
您的方法的“现有Java名称”是"getXAxis",或者对于布尔值[=37],它可能是"isXAxis" =].
“现有 Java 名称 的 中间是 "XAxis"。其中的 "first two characters" 是 "XA",所以它保持原样,没有资本化。
有一种方法可以将方法名称显式映射到具有显式 BeanInfo 的 属性 名称,但很少使用。
顺便说一句,JavaBeans 1.01 规范的日期是 1997 年 8 月。它被积极使用了 18 年。下载页面: http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html