第二步: 
建立一个struts.xml放置src目录
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"        "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>     <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>     <constant name="struts.devMode" value="false"></constant>     <constant name="struts.i18n.encoding" value="UTF-8"></constant>     <constant name="struts.serve.static.browsercade" value="false"></constant>     <constant name="struts.custom.i18n.resources" value="message"></constant>     <constant name="struts.objectFactory" value="spring"></constant>     <!--<constant name="struts.action.extension" value="action"></constant>-->     <include file="/config/struts/struts-login.xml"></include>     <include file="/config/struts/struts-logistics.xml"></include> </struts>

解决方案 »

  1.   

    第三步: 
    建立一个applicationContext.xml ,该文件目录:src/config/applicationContext.xml: <?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" xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beans             http://www.springframework.org/schema/beans/spring-beans-2.5.xsd            http://www.springframework.org/schema/context            http://www.springframework.org/schema/context/spring-context-2.5.xsd">     <bean id="propertyConfigurer"        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">         <property name="location" value="classpath:config/init.properties" />     </bean>       <bean id="dataSource"        class="org.springframework.jdbc.datasource.DriverManagerDataSource">         <property name="driverClassName">             <value>com.mysql.jdbc.Driver</value>         </property>         <property name="url">             <value>${jdbcUrl}</value>         </property>         <property name="username">             <value>${user}</value>         </property>         <property name="password">             <value>${password}</value>         </property>     </bean>                       <bean id="sessionFactory"        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">         <property name="dataSource" ref="dataSource" />         <property name="mappingResources">             <list>                 <value>config/hbm/TUser.hbm.xml</value>                 <value>config/hbm/TRole.hbm.xml</value>                 <value>config/hbm/TModule.hbm.xml</value>                 <value>config/hbm/TFunction.hbm.xml</value>                 <value>config/hbm/TSendBack.hbm.xml</value>                 <value>config/hbm/TStock.hbm.xml</value>                 <value>config/hbm/TSubstance.hbm.xml</value>             </list>         </property>         <property name="hibernateProperties">             <props>                            <!-- 指定数据库方言 -->                 <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLInnoDBDialect</prop>                  <prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider </prop>                 <!-- 是否根据需要每次自动创建数据库 -->                 <prop key="hibernate.hbm2ddl.auto">update</prop>                 <!-- 显示Hibernate持久化操作所生成的SQL -->                 <!--<prop key="hibernate.show_sql">true</prop>                 --><!-- 到多少sql的时候执行,批量处理 -->                 <prop key="hibernate.jdbc.batch_size">20</prop>                 <!-- 取数据的时候每次从数据库中取出的记录条数 -->                 <prop key="hibernate.jdbc.fetch_size">50</prop>             </props>         </property>         <property name="eventListeners">             <map>                 <entry key="merge">                     <bean                         class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />                 </entry>             </map>         </property>     </bean>           <!-- Transaction manager for a single JDBC DataSource -->     <bean id="transactionManager"        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">         <property name="dataSource" ref="dataSource" />     </bean>     <import resource="classpath:config/spring/applicaitonContext-logistics.xml" />     <import resource="classpath:config/spring/applicaitonContext-login.xml" /> </beans>
      

  2.   

    第四步:init.propertis;目录:src/config/init.properties: driverClass=com.mysql.jdbc.Driver #jdbcUrl=jdbc:mysql://192.168.30.110:3306/tianma?useUnicode=true&characterEncoding=utf-8 jdbcUrl=jdbc:mysql://192.168.30.115:3306/tianma?useUnicode=true&characterEncoding=utf-8 user=root password=admin   log4j.properties  path:src/config/log4j.properties: # level:OFF ,FATAL ,ERROR ,WARN ,INFO ,DEBUG ,ALL log4j.rootLogger=INFO, CONSOLE,DEBUG   log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender #The output of the platform level. Filter #log4j.appender.CONSOLE.Threshold=INFO log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %d{ISO8601} %t:( %c.%M ) %m %n   struts-login.xml path:src/config/struts/struts-login.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"        "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>     <package name="login" extends="struts-default">         <action name="loginAction" class="com.erp.action.UserAction"            method="login">             <result name="success">/jsp/template/index.jsp</result>             <result name="error">/login.jsp</result>         </action>     </package> </struts>
      

  3.   

    SO SORRY! 本来打算上传一个自己搭建的比较通用的框架,公司禁网了,又不能上传附件,只能一个一个的把配置文件上传,上传时忘了以代码形式上传
      

  4.   

    <?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" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:config/init.properties" /> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>${jdbcUrl}</value> </property> <property name="username"> <value>${user}</value> </property> <property name="password"> <value>${password}</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mappingResources"> <list> <value>config/hbm/TUser.hbm.xml</value> <value>config/hbm/TRole.hbm.xml</value> <value>config/hbm/TModule.hbm.xml</value> <value>config/hbm/TFunction.hbm.xml</value> <value>config/hbm/TSendBack.hbm.xml</value> <value>config/hbm/TStock.hbm.xml</value> <value>config/hbm/TSubstance.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <!-- 指定数据库方言 --> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLInnoDBDialect</prop> <prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider </prop> <!-- 是否根据需要每次自动创建数据库 --> <prop key="hibernate.hbm2ddl.auto">update</prop> <!-- 显示Hibernate持久化操作所生成的SQL --> <!--<prop key="hibernate.show_sql">true</prop> --><!-- 到多少sql的时候执行,批量处理 --> <prop key="hibernate.jdbc.batch_size">20</prop> <!-- 取数据的时候每次从数据库中取出的记录条数 --> <prop key="hibernate.jdbc.fetch_size">50</prop> </props> </property> <property name="eventListeners"> <map> <entry key="merge"> <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" /> </entry> </map> </property> </bean> <!-- Transaction manager for a single JDBC DataSource --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <import resource="classpath:config/spring/applicaitonContext-logistics.xml" /> <import resource="classpath:config/spring/applicaitonContext-login.xml" /> </beans>