我尝试注入一个 applicationScoped Bean。我在JSF2 ApplicationScope bean 实例化时发现了类似的主题?并 在任何 Servlet 相关类中按名称获取 JSF 托管 bean
在 faces 上下文中使用 jsf 方式一切都很好(WebsitesController 是 AppScoped):
FacesContext context = FacesContext.getCurrentInstance();
WebsiteController websitesController = context.getApplication().evaluateExpressionGet(context, "#{websitesController}", WebsitesController.class);
随着两个溢出线程的注入,它不起作用。我的代码:
@ManagedBean(eager=true)
@ApplicationScoped
public class WebsitesController implements Serializable {
...}
现在我尝试了
@ManagedBean(name = "shopController")
@ViewScoped
public class ShopController {
{Injection-Statement}
private WebsitesController websitesController;
我尝试了以下陈述:
@ManagedProperty("#{websitesController}")
@Inject
@EJB
我的错是什么?