发现在tomcat加载的时候,spring的注入式完成了的,但是在进行action调用service时,取到的service是null,调用service方法就会报“空异常”,这个实际上是struts2与spring整合是出现了问题。struts中action的class没有使用spring的bean对应的id,而是自己重新写了action的类路径(com.test.action.XXXAction),这相当于出现new了一个对象,乜有使用spring的action,所以会出现这样的问题。
这里只需要将struts中action对应的class改为spring的bean对应的id就可以了!
<bean id="OnlineRechargeAction" class="com.trace.action.OnlineRechargeAction">
<property name="onlineRechargeService" ref="OnlineRechargeService" />
</bean>
<bean id="OnlineRechargeService" class="com.trace.webservice.impl.OnlineRechargeServiceImpl">
<property name="onlineRechargeDao" ref="OnlineRechargeDao" />
</bean>
<bean id="OnlineRechargeDao" class="com.trace.dao.impl.OnlineRechargeDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<action name="onlineRechargeAction" class="OnlineRechargeAction">
<result name="success" type="redirect">/recharge.action</result>
</action>
分享到:
相关推荐
Hibernate struts2 spring 整合学生信息管理系统源码及文档
对struts2和spring进行整合,希望对想学习该技术的人有一些帮助!
5.struts2_spring struts spring 整合 以上功能包含完整示例代码 Eclipse Java EE IDE for Web Developers. Build id: 20090920-1017 Tomcat6.0 下编译运行通过 struts版本 struts-2.2.3.1 sping版本 spring-...
struts2整合spring、hibernate的jar包
简单的 struts2 spring ibatis 整合架构
自己写的一个SSH整合开发的实例,入门级的,思路清晰非常适合新手。
一个自己做的简单的struts2 和Spring3的一个实例,对初学者有很大帮助,都可以看懂的,呵呵。
struts2 spring hibernate 整合
struts和spring整合的2种方式
使用mysql数据库的struts2 spring hibernate整合简单示例,也可参考我的:“struts2 spring hibernate整合要点、注意点”这篇文档来配置
整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4),搭建项目架构原型。 项目架构原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6。 此外,还有:log4j、slf4j、junit4、ehcache等知识点。 项目...
Struts2 hibernate spring 整合案例
struts2 spring hibernate 整合过程 希望能对你有帮助,谢谢
struts+spring+hibernate整合
用DelegatingRequestProcessor和DelegatingActionProxy两种方法实现struts和spring的整合,不同的地方就在struts-config.xml文件中,当前文件中DelegatingRequestProcessor是注释的。
struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码
struts struts hibernate spring 整合 PUBhibernstruts hibernate spring 整合 PUBate spring 整合 PUB
mybatis struts2 spring 整合
SSH(struts2,Hibernate,Spring)整合及测试亲测可用,百分之白亲测可用。
S2SH整合 struts2 spring4 hibernate4