gpt4 book ai didi

java - 关于jsf bean注入(inject)spring bean的一个问题

转载 作者:行者123 更新时间:2023-11-30 11:54:11 26 4
gpt4 key购买 nike

我在给jsf bean注入(inject)spring bean的时候遇到了一个问题,这会导致 javax.faces.FacesException(无法实例化类), javax.faces.el.E​​valuationException

这是我的 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.E​​valuationException

最佳答案

您需要在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com