SSH框架调整 xml配置文件解析

SSH框架整合 xml配置文件解析
SSH框架整合,将struts.xml配置文件里的action的class写成bean的id将hibernate里的数据库相关的配置写在spring的配置文件里。
例如(注意红色字体):

这是struts.xml配置文件里配置action:
<action name="login" class="RegisterAction">
<result name="sucess">/sucess.jsp</result>
<result name="error">/error.jsp</result>
</action>

spring的配置文件:applicationContext.xml:
这是在spring配置文件里配置bean:
<bean id="RegisterAction" class="com.action.RegisterAction">
<property name="user" ref="User"></property>
</bean>

下面这段是将hibernate的配置文件里的相关内容配置在spring的配置文件里:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mysql?useUnicode=true&amp;characterEncoding=utf8">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></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.show_sql">true</prop>
</props>
  </property>
      <property name="mappingLocations">   
             <list> 
//下面这一句是  类的映射文件地址
                <value>classpath:/com/hibernate/*.hbm.xml</value> 
           </list> 
        </property>
</bean>

--------=====
下面是类的映射文件:
<class name="User" table="userinsert" >====name是类的名字,table是数据库中表名 ,类名和表名一致也可以不指定。
<id name="username" type="java.lang.String">=====id是主键,name
<column name="username" length="30" />  ====这是表中对应字段的名称,长度
            <generator class="assigned" />
            </id>
<property name="pass" type="java.lang.String"></property>===对应表中字段名
<column name="pass" length="20"/>如果类属性名和数据库的字段名一致可以不用指定

</class>