struts2_spring3_hibernate3_1.0 整合配置

lishoubin 11年前發布 | 982 次閱讀 Android M

1.web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="   <display-name></display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <listener>
    <description>Spring core configuration</description>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>
</web-app>
2.applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="
    xmlns:xsi="     xmlns:p="     xsi:schemaLocation="http://www.springframework.org/schema/beans ;
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://localhost:3306/myssh">
        </property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!-- if use the hibernate.cfg.xml as dataSource configuration, cancel the annotations -->
        <!-- remove other properties and dataSource bean. -->   
        <property name="configLocation" value="classpath:hibernate.cfg.xml" />         
        <!--
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/hzboy/orm/Userinfo.hbm.xml</value>
            </list>
        </property>
         -->
    </bean>   
    <bean id="userAct" class="com.hzboy.action.UserManagerAct" scope="prototype">
        <property name="userService" ref="userService"></property>
    </bean>   
    <bean id="userService" class="com.hzboy.service.UserManagerService">
        <property name="dao" ref="dao"></property>
    </bean>   
    <bean id="dao" class="com.hzboy.dao.BaseDao">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

 本文由用戶 lishoubin 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!