通过org.springframework.web.jsf.FacesContextUtils获得org.springframework.web.context.WebApplicationContext
之后就可以获得spring环境中的beans
具体代码如下:
WebApplicationContext webApplicationContext=FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance())
webApplicationContext.getBean("beanname");
JSF中获取Spring Beans
本文介绍如何在JSF应用中使用org.springframework.web.jsf.FacesContextUtils来获取Spring环境中的WebApplicationContext,进而访问到所需的beans。具体实现过程包括通过FacesContext获取当前实例并调用getWebApplicationContext方法。
628





