加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – ELException错误读取类型

发布时间:2020-12-14 05:32:36 所属栏目:Java 来源:网络整理
导读:当我显示我的jsp页面,尝试在Person类型中调用一个定义的getCurrentlocation()函数时,我收到异常. 该函数由jsp文件中的${person.currentlocation}调用. type Exception reportmessage javax.el.ELException: Error reading 'currentlocation' on type **.pers
当我显示我的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技术很新.也许有人可以帮助我!

谢谢,
本杰明

解决方法

这个特殊的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的问题.这只是你自己的代码,导致了这个问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读