在配置文件中managerService这个bean有定义吗

解决方案 »

  1.   

    楼主把错误代码贴出来嘛
    <listener> 
    <listener-class> 
    org.springframework.web.context.ContextLoaderListener 
    </listener-class> 
    </listener> 
    这个是你的监听,但是我没有看见你的监听的参数啊!~!
      

  2.   

    配置文件部队啊,配置spring的地方,没有加入配置文件啊
    像楼上说的问题看看
      

  3.   


      <!-- spring -->
      <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      
      <listener>
       <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
      </listener>
      <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/classes/com/lip/springcfg/applicationContext.xml</param-value>
      </context-param>
      

  4.   

    看了这么久,其实没有看多大明白,觉得有点乱,呵呵,不要介意,呵呵,你这里就是用的struts+spring,你到网上去看看吧,其实不是注入的问题,就是一个struts是负责页面相关的m或者v,spring就是一个control,
      

  5.   

    错误是空指针异常
    也就是本应被注入的bean managerService为空,所以调用其方法时就会报空指针..我自己调试是发现,一般的bean 注入没有问题(如上userLoginBean)所以可能是由于managerService是由spring代理器所返回的bean才会空调试时服务器启动也运行了setManagerService()的方法,但注入进来的是个空对象.setManagerService就是个javaBean,负责执行dao的方法;它的意义的作为target来实现springAOP的声明式事务之前我是用mian函数测试managerService这个bean是可以使用的:如下使用的spring ApplicationContext 的 getBean方法调用的。
    ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");  
    CustomerManagerService ms=(CustomerManagerService)ctx.getBean("customerServiceManager"); 
    ms.insertCustomer(c,a);
      

  6.   

    可能我表达的还是不太明白
    重新总结一下:
    简单的说就是说我有两个bean:  userLoginBean和managerServiceokuserLoginBean被成功注入了。
    managerService却没有,一样的配置奇怪。如下:
    <property name="managerService"> 
        <ref bean="customerServiceManager"/> 
    </property> 
    <property name="userLoginBean"> 
        <ref bean="userLoginBean"/> 
    </property> 恩,调试时发现
    1.setManagerService()方法被调用了,但是诸如进来的就是null。
    2.自己写个man函数,用ApplicationContext的getBean方法调用managerService,没有问题,对象存在,可以正常使用。猜想:
    由于managerService是通过spring代理器来管理封装的,所以可能和着有关。(其他bean都没有问题)补充:
    我的框架是一个标准的ssh,之所以用到代理是为了实现spring的声明式事务。
    感觉struts和spring的整合应该没有太大问题,因为实际上我只是在原来的构架上加上如用声明式事务实现的bean
      

  7.   

    struts-config.xml
    把action的type改成 type="org.springframework.web.struts.DelegatingActionProxy" 控制权交给spring