Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSF2.0 SpringBean注入_Java_Spring_Jsf 2 - Fatal编程技术网

Java JSF2.0 SpringBean注入

Java JSF2.0 SpringBean注入,java,spring,jsf-2,Java,Spring,Jsf 2,我正在使用以下spring的罐子: spring-web-2.5.5.jar spring-context-2.5.5.jar spring-core-2.5.5.jar spring-orm-2.5.5.jar spring-support-2.0.8.jar spring-security-taglibs-2.0.3.jar spring-security-acl-2.0.3.jar spring-security-core-2.0.4.jar spring-aop-2.5.5.jar sp

我正在使用以下spring的罐子:

spring-web-2.5.5.jar
spring-context-2.5.5.jar
spring-core-2.5.5.jar
spring-orm-2.5.5.jar
spring-support-2.0.8.jar
spring-security-taglibs-2.0.3.jar
spring-security-acl-2.0.3.jar
spring-security-core-2.0.4.jar
spring-aop-2.5.5.jar
spring-jdbc-2.5.5.jar
spring-tx-2.5.5.jar
问题是在从
jsf1.2
迁移到
jsf2.0
bean之后,在faces上下文中定义的bean不能注入到具有会话范围的托管bean中。例如:

<managed-bean>
    <managed-bean-name>bannersController</managed-bean-name>
    <managed-bean-class>jaxp.com.controller.BannersController</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>bannerDao</property-name>
            <value>#{bannerDao}</value>
        </managed-property>
</managed-bean>

横幅控制器
jaxp.com.controller.BannersController
要求
班纳道
#{bannerDao}


当我将bean的作用域替换为会话时,它将正常工作。但是现在,托管属性只是空的。在我们迁移到JSF2.0之前,它已经工作了。出了什么问题以及如何修复

UPD:如果我将托管bean范围设置为查看范围,它也可以正常工作/

inject spring service
@ManagedProperty("#{handlerService}")
private HandlerService handlerService = null;
///add setter
Spring service:

@Service("handlerService")
@Component
public class HandlerService {
    @Autowired
    private DomainService domainService;

faces-config.xml
   <application>     
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>                  
    </application>
------------
web.xml

 <context-param>
        <param-name>contextClass</param-name>
        <param-value>
            org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        </param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>com.myspringconfgigclass.CommonCoreConfig</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>  
injectspring服务
@ManagedProperty(“{handlerService}”)
私有HandlerService HandlerService=null;
///添加设置器
春季服务:
@服务(“handlerService”)
@组成部分
公共类搬运服务{
@自动连线
私有域名服务域名服务;
faces-config.xml
org.springframework.web.jsf.el.SpringBeanFacesELResolver
------------
web.xml
上下文类
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
上下文配置位置
com.myspringconfgigclass.CommonCoreConfig
org.springframework.web.context.ContextLoaderListener

停止混合不同的spring版本…spring 2.5.5和2.0.8不能混合。也不确定为什么dao是原型范围,应该是singleton imho。确保为JSF配置了正确的解析器,它只能在正确的集成设置下工作…请参阅标签完整答案中的完整答案:[spring bean注入JSF bean][1] [1]:
inject spring service
@ManagedProperty("#{handlerService}")
private HandlerService handlerService = null;
///add setter
Spring service:

@Service("handlerService")
@Component
public class HandlerService {
    @Autowired
    private DomainService domainService;

faces-config.xml
   <application>     
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>                  
    </application>
------------
web.xml

 <context-param>
        <param-name>contextClass</param-name>
        <param-value>
            org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        </param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>com.myspringconfgigclass.CommonCoreConfig</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>