日期:2014-05-20  浏览次数:20828 次

ssh整合问题
我用的是spring2.5,hiernate3.2,struts1.2。做一个简单的用户注册时出问题了!
applicationContext.xml
XML code
<?xml version="1.0" encoding="GB18030"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
    <bean id="dataSource"
        class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:comp/env/jdbc/bbs"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.connection.autocommit">true</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="mappingResources">
           <list>
              <value>com/jun/bbs/domel/User.hbm.xml</value>
           </list>
        </property>
    </bean>
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
           <ref bean="sessionFactory"/>
        </property>
    </bean>
    <bean id="userdao" class="com.jun.bbs.dao.UserDao" abstract="true"></bean>
    <bean id="userdaoimpl" class="com.jun.bbs.dao.impl.UserDaoImpl" parent="userdao">
        <property name="hibernateTemplate">
            <ref bean="hibernateTemplate"/>
        </property>
    </bean>
    <bean name="/jsp/user" class="com.jun.bbs.struts.action.UserAction">
            <property name="userdao">
            <ref bean="userdaoimpl"/>
         </property>
    </bean>
    </beans>

struts-config.xml
XML code

<?xml version="1.0" encoding="GB18030"?>
<!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>
  <data-sources />
  <form-beans >
    <form-bean name="userForm" type="com.jun.bbs.struts.form.UserForm" />
  </form-beans>
  <global-exceptions />
  <global-forwards />
  <action-mappings>
    <action
      attribute="userForm"
      input="/jsp/errors.jsp"
      name="userForm"
      parameter="status"
      path="/jsp/user"
      scope="request"
      type="com.jun.bbs.struts.action.UserAction">
      <forward name="registersuccess" path="/jsp/index.jsp"/>
      <forward name="registerfailure" path="/jsp/register.jsp"/>
      </action>
  </action-mappings>
  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
  <message-resources parameter="com.jun.bbs.struts.ApplicationResources" />
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
         <set-property property="pathnames" value="/WEB-INF/validator-rules.xml"/>
  </plug-in>
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
  </plug-in>
</struts-config>