没有什么地方可以记录了,先记录在这吧。

<?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:p="http://www.springframework.org/schema/p"  
    xmlns:aop="http://www.springframework.org/schema/aop"   
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:jee="http://www.springframework.org/schema/jee"  
    xmlns:tx="http://www.springframework.org/schema/tx"  
    xsi:schemaLocation="    
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd  
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd  
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> 
       <!-- 测试bean ,用于测试Spring能正常工作-->
        <bean id="testService" class="com.test.TestService">
        <property name="name" value="xiaoming"/>
        <property name="age" value="12"/>
        </bean>
       <!-- 配置数据源 -->
         <bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName"
			value="com.mysql.jdbc.Driver">
		</property>
		<property name="url"
			value="jdbc:mysql://localhost:3306/wuwenpeng">
		</property>
		<property name="username" value="root"></property>
		<property name="password" value="123"></property>
		
	</bean>
	 <!-- 配置sessionFactory -->  
    <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.MySQL5InnoDBDialect</prop> 
                <prop key="hibernate.show_sql">true</prop> 
                <prop key=" hibernate.hbm2ddl.auto">update</prop>
               
            </props> 
        </property> 
           <property name="mappingResources">

         <list>
            <value>com/wwp/domain/Person.hbm.xml</value>
         </list>
    </property>

        
    </bean>  
  
        
</beans>

bean.xml在src目录下

Spring可以把Hibernate给接管了.

Person bean对象代码为:

package com.wwp.domain;

public class Person {
private Integer id;
private String name;
private String password;
public Integer getId() {
	return id;
}
public void setId(Integer id) {
	this.id = id;
}
public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
}
public String getPassword() {
	return password;
}
public void setPassword(String password) {
	this.password = password;
}
}

测试代码为:

package com.test;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.wwp.domain.Person;

public class TestMain {

	/**
	 *@author wuwp
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ApplicationContext ac=new ClassPathXmlApplicationContext("bean.xml");
		SessionFactory ts=(SessionFactory)ac.getBean("sessionFactory");
		System.out.println(ts.toString());
		Session ss=ts.openSession();
		Transaction tx=ss.beginTransaction();
		Person p=new Person();
		
		p.setName("wwp");
		p.setPassword("wwp1231");
		ss.save(p);
		tx.commit();
		
	}

}


struts1.x的基本配置文件 struts-config.xml

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

<struts-config>
<!-- 配置formbean 用于记录表单数据 -->
  <form-beans >
    <form-bean name="loginForm" type="com.yourcompany.struts.form.LoginForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
 <!-- 配置action的映射,由于ActionServlet拦截了以点do结尾的所有请求,所有action里的path属性加.do组成
 了action的访问路径例如login.do,这里值得注意的是struts中用type来指明类的位置。管理formbean时需保持
 action和formbean的name属性一致
 
  -->
  <action-mappings >
  <!-- action里面的name和form-bean里面的name要一致 -->
    <action
      attribute="loginForm"
      input="/login.jsp"
      name="loginForm"
      path="/login"
      scope="request"
      type="com.yourcompany.struts.action.LoginAction"
     >
      <forward name="fail" path="/fail.jsp" />
      <forward name="sucess" path="/main.jsp" />
    </action>
    <action
      path="/fenpan"
      type="com.yourcompany.struts.action.FenpanAction"
      validate="false" />
    
    

  </action-mappings>
<!-- 实现国际化使用资源,暂时不管 -->
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>