【发布时间】:2026-02-19 16:10:01
【问题描述】:
正如用户前段时间在另一个问题中所建议的那样,我需要在另一个 bean 中注入一个 bean。
所以,我做了以下事情:
@ManagedBean
@RequestScoped
public class Articles {
private String selectedMenu;
@ManagedProperty(value="#{user}")
private UserManager user;
@PostConstruct
public void init() {
if(selectedMenu==null || selectedMenu.trim().isEmpty()) {
this.selectedMenu="0";
}
}
// now here i should access to user.methods
// getter and setter
}
事实上,我无法访问 UserManager 数据。我收到这些错误:
浏览器 malformedXML: INVALID_STATE_ERR: Dom Exception 11
服务器日志
30-nov-2010 15.36.58 javax.faces.component.UIViewRoot$ViewMap put
AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)
30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean
GRAVE: JSF will be unable to create managed bean articles when it is requested. The following problems where found:
- Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.
30-nov-2010 15.36.59 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
GRAVE: com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean articles. The following problems were found:
- Property user for managed bean articles does not exist. Check that appropriate getter and/or setter methods exist.
如果我评论 @ManagedProperty(value="#{user}") 和 private UserManager user; 比我看不到任何错误。所以这就是问题所在。我错了什么?
干杯
【问题讨论】:
-
你在哪里看到这个错误?
-
当我尝试访问这个 bean 时看到了这个错误!
-
@org 的意思是 where,而不是 when。 IE。在服务器日志中,或者在网络浏览器中,或者在天空中,等等
-
+ 发布完整的错误消息
-
哈哈
in the sky摇滚!!我在主题中发布了错误详细信息:) 谢谢大家
标签: java jsf jsf-2 facelets postconstruct