9

getCurrentlocation()显示尝试调用type中定义的函数的 jsp 页面时出现异常Person${person.currentlocation}该函数在 jsp 文件中被调用。

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技术很陌生。也许有人可以帮助我!

谢谢,本杰明

4

1 回答 1

22

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);
}

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

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 来说通常不是问题。只是您自己的代码导致了问题。

于 2012-09-17T18:54:12.050 回答