簡易代碼之家

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            157 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks
          1.web.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
              xmlns:xsi
          ="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
              xsi:schemaLocation
          ="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

              
          <context-param>
                  
          <param-name>contextConfigLocation</param-name>
                  
          <param-value>/WEB-INF/applicationContext*.xml</param-value>
              
          </context-param>
              
          <listener>
                  
          <listener-class>
                      org.springframework.web.context.ContextLoaderListener
                  
          </listener-class>
              
          </listener>

              
          <servlet>
                  
          <servlet-name>action</servlet-name>
                  
          <servlet-class>
                      org.apache.struts.action.ActionServlet
                  
          </servlet-class>
                  
          <init-param>
                      
          <param-name>config</param-name>
                      
          <param-value>
                          /WEB-INF/struts-config.xml,/WEB-INF/struts-config-form.xml,/WEB-INF/struts-config-action.xml
                      
          </param-value>
                  
          </init-param>
                  
          <init-param>
                      
          <param-name>debug</param-name>
                      
          <param-value>3</param-value>
                  
          </init-param>
                  
          <init-param>
                      
          <param-name>detail</param-name>
                      
          <param-value>3</param-value>
                  
          </init-param>
                  
          <load-on-startup>0</load-on-startup>
              
          </servlet>
              
          <servlet-mapping>
                  
          <servlet-name>action</servlet-name>
                  
          <url-pattern>*.do</url-pattern>
              
          </servlet-mapping>
              
          <session-config>
                  
          <session-timeout>120</session-timeout>
              
          </session-config>

              
          <!-- The Usual Welcome File List -->
              
          <welcome-file-list>
                  
          <welcome-file>login.jsp</welcome-file>
              
          </welcome-file-list>

              
          <!-- Tag Library Descriptors-->
              
          <jsp-config>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-bean.tld
                      
          </taglib-location>
                  
          </taglib>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-html.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-html.tld
                      
          </taglib-location>
                  
          </taglib>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-logic.tld
                      
          </taglib-location>
                  
          </taglib>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-nested.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-nested.tld
                      
          </taglib-location>
                  
          </taglib>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-template.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-template.tld
                      
          </taglib-location>
                  
          </taglib>
                  
          <taglib>
                      
          <taglib-uri>/WEB-INF/tld/struts-tiles.tld</taglib-uri>
                      
          <taglib-location>
                          /WEB-INF/tld/struts-tiles.tld
                      
          </taglib-location>
                  
          </taglib>
              
          </jsp-config>
          </web-app>

          2.applicationContext-persistence.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
          "http://www.springframework.org/dtd/spring-beans-2.0.dtd"
          >
          <beans>

              
          <!--  配置數據源 -->
              
          <bean id="dataSource"
                  class
          ="org.apache.commons.dbcp.BasicDataSource"
                  destroy-method
          ="close">
                  
          <property name="driverClassName">
                      
          <value>oracle.jdbc.driver.OracleDriver</value>
                  
          </property>
                  
          <property name="url">
                      
          <value>jdbc:oracle:thin:@localhost:1521:ora9i</value>
                  
          </property>
                  
          <property name="username">
                      
          <value>tom</value>
                  
          </property>
                  
          <property name="password">
                      
          <value>tom</value>
                  
          </property>
              
          </bean>

              
          <!-- 配置Hibernate -->
              
          <bean id="sessionFactory"
                  class
          ="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  
          <property name="dataSource">
                      
          <ref local="dataSource" />
                  
          </property>
                  
          <property name="mappingResources">
                      
          <list>
                          
          <value>com/example/entity/User.hbm.xml</value>
                      
          </list>
                  
          </property>
                  
          <property name="hibernateProperties">
                      
          <props>
                          
          <prop key="hibernate.dialect">
                              org.hibernate.dialect.Oracle9Dialect
                          
          </prop>
                          
          <prop key="hibernate.show_sql">true</prop>
                      
          </props>
                  
          </property>
              
          </bean>

              
          <!-- 配置事務 -->
              
          <bean id="transactionManager"
                  class
          ="org.springframework.orm.hibernate3.HibernateTransactionManager">
                  
          <property name="sessionFactory">
                      
          <ref local="sessionFactory" />
                  
          </property>
              
          </bean>

              
          <bean id="transactionInterceptor"
                  class
          ="org.springframework.transaction.interceptor.TransactionInterceptor">
                  
          <property name="transactionManager" ref="transactionManager" />
                  
          <property name="transactionAttributes">
                      
          <props>
                          
          <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                          
          <prop key="save*">PROPAGATION_REQUIRED</prop>
                          
          <prop key="update*">PROPAGATION_REQUIRED</prop>
                          
          <prop key="delete*">PROPAGATION_REQUIRED</prop>
                      
          </props>
                  
          </property>
              
          </bean>

              
          <bean id="transactionProxyCreator"
                  class
          ="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
                  
          <property name="proxyTargetClass" >
                         
          <value>true</value>
                    
          </property>
                  
          <property name="beanNames">
                      
          <list>
                          
          <value>*Service</value>
                      
          </list>
                  
          </property>
                  
          <property name="interceptorNames">
                      
          <list>
                          
          <value>transactionInterceptor</value>
                      
          </list>
                  
          </property>
              
          </bean>

          </beans>
          3.applicationContext-action.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
          <beans>

              
          <!-- example -->
              
          <bean name="/login" class="com.example.actions.LoginAction">
                  
          <property name="userService">
                      
          <ref bean="userService" />
                  
          </property>
              
          </bean>

          </beans>
          4.applicationContext-service.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
          <beans>

              
          <!-- example -->
              
          <bean id="userService"
                  class
          ="com.example.service.UserService">
                  
          <property name="userDAO">
                      
          <ref bean="userDAO" />
                  
          </property>
              
          </bean>
              
          </beans>
          5.applicationContext-dao.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
          <beans>

              
          <!-- example -->
              
          <bean id="userDAO" class="com.example.dao.UserDAO">
                  
          <property name="sessionFactory">
                      
          <ref bean="sessionFactory" />
                  
          </property>
              
          </bean>
              

          </beans>
          6.struts-config.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

          <struts-config>

              
          <!-- Global-Forwards -->
              
          <global-forwards>
                  
          <forward name="login" path="/login.do" />
                  
          <forward name="welcome" path="/welcome.do" />
              
          </global-forwards>

              
          <!-- Resources -->
              
          <message-resources parameter="ApplicationResources" />

          </struts-config>

          7.struts-config-action.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

          <struts-config>
              
          <action-mappings>
              
                  
          <!-- example -->
                  
          <action path="/login" name="loginForm" scope="request"
                      type
          ="org.springframework.web.struts.DelegatingActionProxy" input="/login.jsp">
                      
          <forward name="success" path="/welcome.jsp" />
                      
          <forward name="failure" path="/login.jsp" />
                  
          </action>
                  
                  
              
          </action-mappings>
          </struts-config>

          8.struts-config-form.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

          <struts-config>
              
          <form-beans>

                  
          <!-- example -->
                  
          <form-bean name="loginForm"
                      type
          ="com.example.forms.LoginForm">
                  
          </form-bean>


              
          </form-beans>
          </struts-config>

          posted on 2009-04-23 10:46 Jakin.zhou 閱讀(1170) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 陕西省| 永仁县| 崇明县| 绩溪县| 雅江县| 阳西县| 甘德县| 荣昌县| 安乡县| 宁都县| 博乐市| 普定县| 昌吉市| 高青县| 高尔夫| 重庆市| 镇坪县| 平阳县| 叶城县| 姜堰市| 揭西县| 保德县| 青州市| 凤山市| 集安市| 嘉禾县| 曲松县| 棋牌| 余姚市| 屯昌县| 简阳市| 镇原县| 潼关县| 华阴市| 浦县| 五大连池市| 九寨沟县| 雷州市| 甘南县| 徐州市| 陇川县|