日期:2014-05-18  浏览次数:20792 次

jsf找不到spring bean问题
日志:
2007-01-08   15:51:12,531   [main]   WARN     org.apache.commons.digester.Digester   -   [ManagedBeanRule]{faces-config/managed-bean}   Merge(wyUserBean)
.
.
.
org.springframework.beans.factory.support.DefaultListableBeanFactory   defining   beans   [wyUserDAO,wyUserService];   root   of   BeanFactory   hierarchy((提示生成spring   bean成功))


jsf:         faces-config.xml
<faces-config>
<application>
<variable-resolver> org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>
</application>

<managed-bean>
<managed-bean-name> wyUserBean </managed-bean-name>
<managed-bean-class>
com.wy.web.vo.WyUserBean
</managed-bean-class>
<managed-bean-scope> session </managed-bean-scope>
<managed-property>
<property-name> wyUserService </property-name>
<property-class>
com.wy.service.IWyUserService
</property-class>
<value> #{wyUserService} </value>
</managed-property>
</managed-bean>
</faces-config>


web.xml:
<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<web-app   xmlns= "http://java.sun.com/xml/ns/j2ee "
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "   version= "2.4 "
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<!--   配置Spring   -->
<context-param>
<param-name> contextConfigLocation </param-name>
<param-value> /WEB-INF/applicationContext.xml </param-value>
</context-param>

<context-param>
<param-name> javax.faces.CONFIG_FILES </param-name>
<param-value> /WEB-INF/faces-config.xml </param-value>
</context-param>

<servlet>
<servlet-name> Faces   Servlet </servlet-name> <servlet-class> javax.faces.webapp.FacesServlet </servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name> Faces   Servlet </servlet-name>
<url-pattern> *.faces </url-pattern>
</servlet-mapping>


<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<welcome-file-list>
<welcome-file> /index.faces </welcome-file>
</welcome-file-list>
</web-app>


从日志上看出,第一句提示警告,jsf的bean初始化有误.
接着,后面提示spring   bean初始化成功.

当指向页面时,提示没有找到wyUserService       bean.

------解决方案--------------------
没明白你在问什么?