我在给jsf bean注入(inject)spring bean的时候遇到了一个问题, 这会导致 javax.faces.FacesException(无法实例化类), javax.faces.el.EvaluationException
这是我的 xml 文件:
文件 WEB-INF/components.xml 定义 spring bean
<beans>
<bean id="rambo.api.VideoService"
class="rambo.impl.VideoServiceImpl">
<!-- some properties ... -->
</bean>
</beans>
文件 WEB-INF/faces-config.xml 定义 jsf beans
<managed-bean>
<description>Video Home Bean</description>
<managed-bean-name>videoBean</managed-bean-name>
<managed-bean-class>rambo.tool.VideoBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<description>videoService</description>
<property-name>videoService</property-name>
<value>#{Components["rambo.api.VideoService"]}</value>
</managed-property>
<!-- Other properties -->
</managed-bean>
文件videoMain.jsp:
在resourceToolExists中:videoBean使用了videoService的一些方法
<h:panelGroup rendered="#{! videoBean.resourceToolExists" >
<%@ include file="videoNoResource.jsp" %>
</h:panelGroup>
这里得到: javax.faces.FacesException(无法实例化类 rambo.impl.VideoServiceImpl), javax.faces.el.EvaluationException
最佳答案
您需要在 faces-config.xml 文件中配置一个 spring elresolver。 spring elresolver 将评估您的 el express 并获取在 spring 中定义的 bean 对象 请查看http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/jsf/el/SpringBeanFacesELResolver.html
关于java - 关于jsf bean注入(inject)spring bean的一个问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5848551/