无法访问非托管Bean类内的托管属性吗? [英] Is it not possible to access a managed property inside a non managed bean class?

查看:88
本文介绍了无法访问非托管Bean类内的托管属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否无法通过使用@ManagedProperty(value="#{beanName}")访问非托管Bean类内的托管属性?

Is it not possible to access a managed property inside a non managed bean class by using @ManagedProperty(value="#{beanName}")?

在尝试执行此操作时,我得到一个NullPointerException

I am getting a NullPointerException while trying to do that!

推荐答案

如果在访问其属性

If you are sure that bean is alive when you are accessing its property you can fetch it from FacesContext and access its property, but you can't inject a managed bean as property in a normal Java class.

这篇关于无法访问非托管Bean类内的托管属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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