【问题标题】:ELException Error Reading ... on typeELException Error Reading ... 类型
【发布时间】:2012-09-17 17:29:30
【问题描述】:

在显示我的 jsp 页面时遇到异常,该页面试图调用在类型 Person 中定义的函数 getCurrentlocation()。 该函数由jsp文件中的${person.currentlocation}调用。

type Exception report

message javax.el.ELException: Error reading 'currentlocation' on type **.person.Person

description The server encountered an internal error that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: javax.el.ELException: Error reading 'currentlocation' on type **.person.Person

我对 jsp 技术还很陌生。也许有人可以帮助我!

谢谢, 本杰明

【问题讨论】:

  • 可能是错字,可能是getCurrentLocation()?还要检查 getter 是否是公开的。
  • 我还检查了拼写错误...这个函数不是getter,而是它的public。它从对象的某些字段中计算返回值。
  • 抱歉各位,发现问题了...我超出了数组的范围...谢谢!

标签: java jsp el


【解决方案1】:

这个特殊的ELException 是一个包装异常。这通常仅在调用 getter 方法本身引发异常时才会引发。当这个ELException 被抛出时,会在幕后发生类似下面的事情:

Object bean;
String property;
Method getter;
// ...

try {
    getter.invoke(bean);
} catch (Exception e) {
    String message = String.format("Error reading '%s' on type %s", property, bean.getClass().getName());
    throw new ELException(message, e);
}

您应该在堆栈跟踪中进一步查看真正的根本原因。完整的堆栈跟踪通常仅在服务器日志中可用。真正的根本原因是堆栈跟踪的最底层异常。例如。以下是由 getter 方法中抛出的 NullPointerException 引起的。

javax.el.ELException: Error reading 'currentlocation' on type **.person.Person
    at ...
    at ...
    at ...
Caused by: java.lang.NullPointerException
    at **.person.Person.getCurrentlocation(Person.java:42)
    at ...
    at ...

有关真正根本原因的信息(异常类型和行号)应该为您提供足够的线索来确定问题。

同样,这对于 EL 来说不是问题。只是您自己的代码导致了问题。

【讨论】:

  • 感谢您提供的信息。我已经发现我的错误了! (IndexOutOfBounds...)。本杰明
猜你喜欢
  • 2017-06-29
  • 2023-03-14
  • 1970-01-01
  • 2019-08-09
  • 1970-01-01
  • 1970-01-01
  • 2021-11-03
  • 2021-12-22
  • 1970-01-01
相关资源
最近更新 更多