JSF2 : inject service objects to managedbean from Spring?

前端 未结 2 917
余生分开走
余生分开走 2021-01-05 07:46

I have tested this, trying to inject an service object to a @ManagedBean, but it failed with a nullpointerexception, being the userService is null.

I am currently us

相关标签:
2条回答
  • 2021-01-05 08:27

    missing variable resolver in faces-config.xml

    <application>  
      <variable-resolver>  
        org.springframework.web.jsf.DelegatingVariableResolver 
      </variable-resolver>  
     </application> 
    

    missing RequestContextListener listener in web.xml

    <listener> 
      <listener-class>
        org.springframework.web.context.request.RequestContextListener
      </listener-class>  
    </listener>  
    
    0 讨论(0)
  • 2021-01-05 08:38

    In your applications context xml define a bean for "UserService" for example,

    <bean id="userService" class="org.albertkam.yourclassname"/>
    
    0 讨论(0)
提交回复
热议问题