ELException错误读取...类型 [英] ELException Error Reading ... on type

查看:252
本文介绍了ELException错误读取...类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm getting an exception when displaying my jsp page that tries to invoke a function defined getCurrentlocation() in type Person. The function is invoked by ${person.currentlocation} in the jsp file.

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

I am pretty new to jsp technology. Maybe someone could help me out!

谢谢,
本杰明

Thanks, Benjamin

推荐答案

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

This particular ELException is a wrapper exception. This is usually only thrown when invoking the getter method itself has thrown an exception. Something like the following is happening under the covers when this ELException is been thrown:

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 引起的。

You should look further down in the stacktrace for the real root cause. The complete stacktrace is usually just available in server logs. The real root cause is the bottommost exception of the stacktrace. E.g. the below one is caused by a NullPointerException being thrown in the getter method.

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 ...

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

The information about the real root cause (the exception type and the line number) should give you enough clues to nail down the problem.

同样,这通常不是EL的问题。这只是你自己的代码导致了这个问题。

Again, this is not a problem with EL in general. It's just your own code which caused the problem.

这篇关于ELException错误读取...类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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