javax.el.PropertyNotFoundException:类"xxx"没有可读的属性"yyy" [英] javax.el.PropertyNotFoundException: The class 'xxx' does not have a readable property 'yyy'

查看:79
本文介绍了javax.el.PropertyNotFoundException:类"xxx"没有可读的属性"yyy"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的会话范围内使用CDI托管的bean:

I've the below session scoped CDI managed bean:

@Named
@SessionScoped
public class RegisterController implements Serializable {   
    private static final long serialVersionUID = 1L;

    @Inject
    private MitgliedAbc mitgliedAbc;

    public MitgliedAbc getMitgliedABC() {
        return mitgliedAbc;
    }

    public void setMitgliedAbc (MitgliedAbc mitgliedAbc) {
        this.mitgliedAbc = mitgliedAbc;
    }

}

以下是JSF形式的输入:

And the following input in a JSF form:

<h:inputText value="#{registerController.mitgliedAbc.mgEmail}" />

部署到GlassFish 4.1并在浏览器中打开页面时,将引发以下异常:

When deploying to GlassFish 4.1 and opening the page in browser, the following exception is thrown:

javax.el.PropertyNotFoundException:/register.xhtml @ 27,66 value =#{registerController.mitgliedAbc.mgEmail}":该类 'com.example.RegisterController'不 具有可读的属性"mitgliedAbc".

javax.el.PropertyNotFoundException: /register.xhtml @27,66 value="#{registerController.mitgliedAbc.mgEmail}": The class 'com.example.RegisterController' does not have a readable property 'mitgliedAbc'.

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

javax.el.PropertyNotFoundException:类"xxx"没有可读的属性"yyy"

这基本上意味着类xxx没有用于属性yyy的(有效)getter方法.

This basically means that the class xxx does not have a (valid) getter method for property yyy.

换句话说,下面的EL表达式应该输出值,

In other words, the following EL expression which should output the value,

#{xxx.yyy}

无法在类xxx上找到public Yyy getYyy()方法.

在特定情况下,使用以下EL表达式,

In your particular case, with the following EL expression,

#{registerController.mitgliedAbc}

它找不到public MitgliedAbc getMitgliedAbc()属性.

确实,该方法不存在.它被命名为getMitgliedABC()而不是getMitgliedAbc().

And indeed, that method doesn't exist. It's named getMitgliedABC() instead of getMitgliedAbc().

相应地固定方法名称以完全匹配getYyy().

Fix the method name accordingly to exactly match getYyy().

public MitgliedAbc getMitgliedAbc() {
    return mitgliedAbc;
}

这篇关于javax.el.PropertyNotFoundException:类"xxx"没有可读的属性"yyy"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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