码迷,mamicode.com
首页 > 编程语言 > 详细

SSH(Struts+spring+hibernate)配置

时间:2019-04-21 21:39:44      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:ice   Opens   hiberna   tor   type   listen   lis   nfa   span   

1、spring和struts

  1)web.xml

    配置spring的ContextLoaderListener(监听器)

    配置Struts的StrutsPrepareAndExecuteFilter(过滤器)

  2)applicationContext.xml

    配置service、dao、bean

    配置Struts的每个action为bean,并指明scope=“prototype”

  3)Struts.xml

    配置每个action,并且class=bean的id

2、spring和hibernate

  1)bean.hbm.xml(每一个bean对应一个,里面包含该bean的各个属性定义描述)

  2)applicationContext.xml

    配置数据库连接和root,pwd等

    配置bean的映射路径(即上面的bean.hbm.xml的路径)

    配置sessionFactory

    配置事务管理(可选)

3、ssh

   解决延迟加载:OpenSessionInViewFilter(作用:为每个请求绑定一个hibernatesession,能够自动被spring失误管理器探测到,当事物完成后并不会关闭session,因此可以在web层进行继续查询数据库加载数据)

   配置web.xml( 在StrutsPrepareAndExecuteFilter配置OpenSessionInViewFilter

    

SSH(Struts+spring+hibernate)配置

标签:ice   Opens   hiberna   tor   type   listen   lis   nfa   span   

原文地址:https://www.cnblogs.com/51python/p/10747090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!