在配置文件中managerService这个bean有定义吗
解决方案 »
- Hibernate表的设计问题,求帮助
- struts2.x和webwork有什么关系?
- Javamail 问题 关于 javax.mail.SendFailedException: Invalid Addresses
- 有没高手帮忙看下下面的异常的意思
- struts2.0 在ACTION中怎么调用struts.properties资源文件?
- 推荐在hibernate基础上构建的快速开发框架,新功能:对ajax的支持,带排序、分页功能的列表
- 学习web service遇到的问题
- jexcelapi怎么样在浏览器中显示excel文件啊?
- !!!!!!(给100分,重大难题)AIX UNIX使用Weblogic有时报String index out of range: -1
- session bean 问题
- hibernate操作数据库,在后台删除了数据,前台却还在,为什么?
- --->>>请问hibernate里面的hql not in 带参数怎么写?
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
这个是你的监听,但是我没有看见你的监听的参数啊!~!
像楼上说的问题看看
<!-- 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>
也就是本应被注入的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);
重新总结一下:
简单的说就是说我有两个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
把action的type改成 type="org.springframework.web.struts.DelegatingActionProxy" 控制权交给spring