以下是部分代码:
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"><web-app>
<!-- 
    <filter>
     <filter-name>encoding</filter-name> 
           <filter-class>com.csl.utility.EncodingFilter</filter-class> 
           <init-param>
             <param-name>encoding</param-name>
             <param-value>UTF-8</param-value>
     </init-param>
    </filter>    
    
    <filter-mapping> 
       <filter-name>encoding</filter-name> 
       <url-pattern>/*</url-pattern>  
     </filter-mapping>  
-->
  
  <display-name>TEST</display-name>
   <!--
  - Location of the XML file that defines the root application context
  - Applied by ContextLoaderListener.
  -->
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/classes/applicationContext-hibernate.xml</param-value>
   </context-param>
   
   <!--
  - Loads the root application context of this web app at startup,
  - by default from "/WEB-INF/applicationContext.xml".
  - Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
  - to access it anywhere in the web application, outside of the framework.
  -
  - The root context is the parent of all servlet-specific contexts.
  - This means that its beans are automatically available in these child contexts,
  - both for getBean(name) calls and (external) bean references.
  
  - If your web container loads listeners first then this will work fine.  Otherwise,
    use the SpringContextServlet to load the context.
     -->
   
   <!--listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener-->
   <servlet>
      <servlet-name>SpringContextServlet</servlet-name>
      <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   
  
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <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</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>  <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>  <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>  <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>  <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
  </taglib></web-app>

解决方案 »

  1.   

    applicationContext-hibernate.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
    <!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= -->  

    <!-- Choose the dialect that matches your "dataSource" definition -->
    <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
    <value>java:comp/env/jdbc/test</value>
    </property>
    </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    <property name="mappingResources">
    <list>
    <value>com/csl/database/User.hbm.xml</value>
    </list>
    </property>

    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
    <prop key="hibernate.show_sql">false</prop>
    </props>
    </property>

    <property name="dataSource">
    <ref bean="myDataSource"/>
    </property>
    </bean>
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    <property name="sessionFactory"><ref local="mySessionFactory"/></property>
    </bean>
    <!-- ***** GENERAL SERVICE *****-->
    <bean id="generalService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="myTransactionManager"/></property>
    <property name="target"><ref local="generalTarget"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="find*">PROPAGATION_REQUIRED,readOnly,-Exception</prop>
    <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
    </props>
    </property>
    </bean> <!-- GeneralTarget primary business object implementation -->
    <bean id="generalTarget" class="com.csl.service.spring.GeneralSpringService">
    <property name="generalDao"><ref local="generalDao"/></property>
    </bean>

    <!-- DAO object: Hibernate implementation -->
    <bean id="generalDao" class="com.csl.service.dao.hibernate.GeneralHibernateDao">
    <property name="sessionFactory"><ref local="mySessionFactory"/></property>
    </bean>     <!-- ***** User Service *****-->
         <bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="myTransactionManager"/></property>
    <property name="target"><ref local="userTarget"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="find*">PROPAGATION_REQUIRED,readOnly,-Exception</prop>
    <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
    </props>
    </property>
    </bean>
      <bean id="userTarget" class="com.csl.service.spring.UserSpringService">
    <property name="generalDao"><ref local="userDao"/></property>
    </bean>
    <bean id="userDao" class="com.csl.service.dao.hibernate.UserHibernateDao">
    <property name="sessionFactory"><ref local="mySessionFactory"/></property>
        </bean>
        
     
        <!-- Add more services here -->

    </beans>
      

  2.   

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <data-sources />
      <form-beans>
          <!-- Locale form bean -->
        <form-bean name="localeForm" type="org.apache.struts.action.DynaActionForm">
          <form-property name="language" type="java.lang.String" />
          <form-property name="country" type="java.lang.String" />
          <form-property name="page" type="java.lang.String" />
        </form-bean>
     
        <form-bean name="loginForm" type="com.csl.struts.form.LoginForm" />  </form-beans>  <global-exceptions />
      <global-forwards />
      
      <action-mappings>
          <action 
         path="/locale" 
         type="com.csl.struts.action.LocaleAction" 
         name="localeForm" 
         scope="request">
           <forward name="success" path="/login.jsp" />
        </action>
        
    <action 
    path="/login" 
    type="com.csl.struts.action.LoginAction" 
    name="loginForm" 
    scope="request" 
    input="/login.jsp"
    validate="false"  >
    <forward name="success" path="/hello.jsp"/>
    <forward name="failure" path="/login.jsp"/>
    </action> 
      </action-mappings>
        <message-resources parameter="com.csl.struts.ApplicationResources" null="false"/>
       <!-- ============================================ Plug Ins Configuration  -->
       <!-- 
           Add multiple validator resource files by setting the pathnames property 
           with a comma delimitted list of resource files to load. 
        -->
      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
        <set-property property="stopOnFirstError" value="true" />
      </plug-in>
      <!--
       For Data converter
      -->
    <!--
      <plug-in className="org.apache.struts.tiles.TilesPlugin">
        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
      </plug-in>
      -->
    </struts-config>
      

  3.   

    [email protected]
    谢谢了哦!
      

  4.   

    [email protected]     谢谢了
      

  5.   

    我都要一份,[email protected],谢谢了!
      

  6.   

    我想要一份 ,    [email protected]     ,谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!谢谢了!
      

  7.   

    [email protected]
    thank you .
      

  8.   

    谢谢楼主:)
    EMAIL: [email protected]
      

  9.   

    [email protected]
    顶上去
      

  10.   

    谢谢!!
    [email protected]
      

  11.   

    [email protected]
    谢谢
      

  12.   

    [email protected]我也要一份,谢谢楼主!
      

  13.   

    搂主堪称及时雨啊 谢谢 [email protected]
      

  14.   

    好消息
    [email protected]
    顶一下
      

  15.   

    [email protected]
    多谢楼主!!!!!!!
      

  16.   

    [email protected]
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GO !!!!!!!!!!!!!!!!!!!!!!!!!!
      

  17.   

    实在是太感谢的啊,[email protected]
      

  18.   

    [email protected]  谢谢!