无法访问非托管Bean类内的托管属性吗

无法访问非托管Bean类内的托管属性吗

本文介绍了无法访问非托管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!

推荐答案

如果在访问其属性获取它并访问其属性,但是不能在常规Java类中将托管bean作为属性注入.

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类内的托管属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:39