一個(gè)登錄驗(yàn)證的例子,涉及到webwork action配置,三者結(jié)合的配置,使用了webwork的攔截器。數(shù)據(jù)庫是mysql

          下面把主要的配置文件列一下。

          xwork.xml

           

          <?xml version="1.0" encoding="ISO-8859-1"?>
          <!DOCTYPE xwork PUBLIC
                  "-//OpenSymphony Group//XWork 1.1.1//EN"
                  "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"
          >
          <!--
             Copyright (c) 2002-2006 by OpenSymphony
             All rights reserved.
          -->
          <xwork>
              
          <include file="webwork-portlet-default.xml"/>


              
          <package name="default" extends="webwork-default">  <!-- namespace="/secure"-->
                  
          <interceptors>
                      
          <interceptor name="isLogin" class="com.hallywang.interceptors.LogInterceptor"/>

                  
          </interceptors>
                  
          <action name="login"
                          class
          ="login">

                      
          <result name="success" type="chain">list</result>

                      
          <result name="loginfail" type="dispatcher">
                          
          <param name="location">/index.jsp</param>
                      
          </result>
                      
          <interceptor-ref name="params"/>
                      
          <interceptor-ref name="model-driven"/>
                      
          <interceptor-ref name="validationWorkflowStack"/>
                  
          </action>

                  
          <action name="list"
                          class
          ="list">
                      
          <result name="success" type="dispatcher">
                          
          <param name="location">/list.jsp</param>
                      
          </result>
                      
          <result name="noLogin" type="dispatcher">
                          
          <param name="location">/index.jsp</param>
                      
          </result>
                      
          <interceptor-ref name="isLogin">
                      
          </interceptor-ref>

                  
          </action>
              
          </package>
              
          <package name="test" namespace="/test" extends="webwork-default">  <!-- namespace="/secure"-->
                  
          <action name="login2"
                          class
          ="login2">

                      
          <result name="success" type="chain">list</result>

                      
          <result name="loginfail" type="dispatcher">
                          
          <param name="location">/index.jsp</param>
                      
          </result>
                      
          <interceptor-ref name="params"/>
                      
          <interceptor-ref name="model-driven"/>
                      
          <interceptor-ref name="validationWorkflowStack"/>
                  
          </action>


              
          </package>
          </xwork>

          spring配置文件

           

          <?xml version="1.0" encoding="UTF-8"?>

          <beans xmlns="http://www.springframework.org/schema/beans"
                 xmlns:xsi
          ="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:aop
          ="http://www.springframework.org/schema/aop"
                 xmlns:tx
          ="http://www.springframework.org/schema/tx"
                 xsi:schemaLocation
          ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"

                 default-autowire
          ="byName" default-lazy-init="true">
            
          <aop:aspectj-autoproxy/>

              
          <!-- 配置 dataSource  -->
              
          <!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                  <property name="driverClassName">
                      <value>com.mysql.jdbc.Driver</value>
                  </property>
                  <property name="url">
                      <value>jdbc:mysql://localhost/test</value>
                  </property>
                  <property name="username">
                      <value>root</value>
                  </property>
                  <property name="password">
                      <value>840301</value>
                  </property>
              </bean>
          -->
              
          <bean id="dataSource"
                    class
          ="com.mchange.v2.c3p0.ComboPooledDataSource"
                    destroy-method
          ="close">
                  
          <property name="driverClass">
                      
          <value>com.mysql.jdbc.Driver</value>
                  
          </property>
                  
          <property name="jdbcUrl">
                      
          <value>jdbc:mysql://localhost/test</value>
                  
          </property>
                  
          <property name="user">
                      
          <value>root</value>
                  
          </property>
                  
          <property name="password">
                      
          <value>root</value>
                  
          </property>
              
          </bean>


              
          <bean id="hibernateProperties"
                    class
          ="org.springframework.beans.factory.config.PropertiesFactoryBean">
                  
          <property name="properties">
                      
          <props>
                          
          <prop key="hibernate.dialect">
                              org.hibernate.dialect.MySQLDialect
                          
          </prop>
                          
          <prop key="hibernate.show_sql">
                              true
                          
          </prop>
                          
          <prop key="hibernate.format_sql">false</prop>
                          
          <prop key="hibernate.use_sql_comments">false</prop>

                          
          <prop key="hibernate.c3p0.testConnectionOnCheckout">
                              false
                          
          </prop>
                          
          <prop key="hibernate.c3p0.idle_test_period">100</prop>
                          
          <prop key="c3p0.testConnectionOnCheckout">true</prop>
                          
          <prop key="c3p0.minPoolSize">10</prop>
                          
          <prop key="hc3p0.maxPoolSize">50</prop>
                          
          <prop key="hc3p0.timeout">600</prop>
                          
          <prop key="c3p0.max_statement">50</prop>
                          
          <prop key="hibernate.c3p0.acquire_increment">1</prop>
                          
          <prop key="hibernate.c3p0.idle_test_period">100</prop>

                      
          </props>
                  
          </property>
              
          </bean>


              
          <!-- 配置sessionFactory  -->
              
          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  
          <property name="dataSource">
                      
          <ref local="dataSource"/>
                  
          </property>
                  
          <property name="mappingResources">
                      
          <list>
                          
          <value>com/hallywang/po/User.hbm.xml</value>
                      
          </list>
                  
          </property>
                  
          <property name="hibernateProperties">
                      
          <ref local="hibernateProperties"/>
                  
          </property>
              
          </bean>

              
          <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                  
          <property name="sessionFactory">
                      
          <ref local="sessionFactory"/>
                  
          </property>
              
          </bean>

              
          <bean id="userDao" class="com.hallywang.dao.impl.UserDaoImpl" scope="prototype">   <!--scope="prototype"-->
                  
          <property name="sessionFactory">
                      
          <ref local="sessionFactory"/>
                  
          </property>
              
          </bean>
              
          <bean id="login" class="com.hallywang.action.LoginAction" scope="prototype">
                  
          <property name="userDao">
                      
          <ref local="userDao"/>
                  
          </property>
              
          </bean>
              
          <bean id="list" class="com.hallywang.action.ListAction" scope="prototype">
                  
          <property name="userDao">
                      
          <ref local="userDao"/>
                  
          </property>
              
          </bean>

              
          <bean id="login2" class="com.hallywang.action.Login2Action" scope="prototype">
                  
          <property name="userDao">
                      
          <ref local="userDao"/>
                  
          </property>
              
          </bean>


              
          <!-- ****************************** AOP TEST **************************-->

          <!--

              <bean id="myAspect" class="com.hallywang.interceptors.MethodAspect">

              </bean>


               <bean id="test" class = "com.hallywang.Test"/>
          -->


          </beans>

          廢話不多說,源代碼傳上來。

          http://dl2.csdn.net/down4/20070719/19173314157.rar

          Feedback

          # re: 最近學(xué)習(xí)webwork+spring+hibernate,自己學(xué)習(xí)過程中的一個(gè)例子 [未登錄]  回復(fù)  更多評(píng)論   

          2007-08-02 14:42 by daniel
          webwork+spring+hibernate都是什么版本的,我試著把這個(gè)項(xiàng)目重新編譯、部署,但沒有成功,找不到webwork-portlet-default.xml文件

          # re: 最近學(xué)習(xí)webwork+spring+hibernate,自己學(xué)習(xí)過程中的一個(gè)例子   回復(fù)  更多評(píng)論   

          2007-08-06 10:25 by Hally
          webwork 2.2.5 spring2.0 hibernate3

          # re: 最近學(xué)習(xí)webwork+spring+hibernate,自己學(xué)習(xí)過程中的一個(gè)例子   回復(fù)  更多評(píng)論   

          2008-06-19 15:47 by wulj
          dd

          posts - 43, comments - 200, trackbacks - 0, articles - 2

          Copyright © Hally

          主站蜘蛛池模板: 南皮县| 长兴县| 慈利县| 基隆市| 漾濞| 双桥区| 北碚区| 濉溪县| 玛沁县| 枣强县| 漠河县| 那坡县| 正镶白旗| 湄潭县| 镇宁| 时尚| 太仓市| 阳原县| 突泉县| 南安市| 诏安县| 海城市| 乌什县| 贡觉县| 新邵县| 宣城市| 海淀区| 砚山县| 阜宁县| 府谷县| 驻马店市| 彭泽县| 班玛县| 崇明县| 永宁县| 诸暨市| 祁阳县| 同仁县| 永清县| 和林格尔县| 清水县|