ELException错误读取...类型

时间:2012-09-17 17:29:30

标签: java jsp el

我在显示试图调用类型getCurrentlocation()中定义的Person函数的jsp页面时遇到异常。 该函数由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技术很陌生。也许有人可以帮助我!

谢谢, 本杰明

1 个答案:

答案 0 :(得分:19)

此特定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);
}

你应该在stacktrace中进一步了解真正的根本原因。完整的堆栈跟踪通常仅在服务器日志中可用。真正的根本原因是堆栈跟踪的最底层异常。例如。下面的一个是由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的问题。这只是你自己的代码导致了这个问题。

相关问题