Chinaunix首页 | 论坛 | 博客
  • 博客访问: 783950
  • 博文数量: 738
  • 博客积分: 7000
  • 博客等级: 少将
  • 技术积分: 5000
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-12 09:00
文章分类

全部博文(738)

文章存档

2011年(1)

2008年(737)

我的朋友

分类:

2008-09-12 09:02:18

    一.struts 2 与 spring2
   
    struts2 本身就采用了类似于spring的IOC容器机制,可以利用struts2官方提供的插件struts2-spring-plugin-2.0.11.1.jar,直接与spring进行整合,配置文件中只需要设置
    struts.objectFactory=spring
    这样,就将struts2的对象管理交给了spring2的IOC容器。
    在struts.xml中配置的action
   
   
    /jsp/server_info/server_info_list.jsp
   

    在spring的配置文件中配置的bean
   
               
               
            

                  可以看出,struts2可以直接只用在spring2中配置的bean,引用过来作为action。
                  这样struts2就可以跑在spring2里面了.

                  另外,在web.xml中还有这些内容:
                   
                contextConfigLocation
                classpath:properties/work-assistant*.xml
           

            加载spring的配置文件
           
            org.springframework.web.context.ContextLoaderListener
           

            设置spring的context listener
           
                struts2
                org.apache.struts2.dispatcher.FilterDispatcher
           

           
                struts2
                /*
           

            设置struts2的dispatcher。

    二.hibernate3 与 spring2

    Spring 与 hibernate结合的时候,配置文件修改比较多。首先是hibernate的自身的配置被集成到了spring的配置文件中了.

    1.配置datasource:
                p:driverClassName="${hibernate.connection.driver_class}"
            p:url="${hibernate.connection.url}"
            p:username="${hibernate.connection.username}"
        p:password="${hibernate.connection.password}"/>

[1]  

【责编:Ken】

--------------------next---------------------

阅读(282) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~