`
limingcai
  • 浏览: 110504 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

struts1.2 和spring ,hibernate整合一起

    博客分类:
  • JAVA
阅读更多
struts里面的配置 这个是从spring里拿到的bean path必须跟bean名相同 
   path="/login"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy">  <!--使用代理  就是用spring 托管 -->

    <!-- 交给Spring管理,必须有这个配置启动Spring -->
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationServerl.xml"/>
</plug-in>

这是spring 管理struts的配置
<!-- 把action交给spring 托管    这是struts 和spring的整合-->
<bean name="/login" class="com.purang.model.ebs.action.LoginAction"
   abstract="false" lazy-init="default"  autowire="default">
<property name="loginService" ref="loginServicess" />
</bean>
为什么:<bean id="personDAO" class="com.deng.PersonDAO">直接在spring里面直接写可以,而action非要托管才能注入,不能象server啊 dao之类的直接在applicationContext.xml里面写配置。



因为Action 类不是普通的类似于我们自己写的 dao层 或者service层 的类,

它是由Struts 框架来支持产生的,所以说不能简单的用类似于dao层或者 service层

的依赖注入方式来,所以要使用Spring 中的 DelegatingActionProxy(授权Action代理),实现了针对实际Action的调用代理,struts最终调用的将是由

spring管理的Action实例,这样客户端发送的各种请求就可以用spring的Ioc设计思

想实现了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics