1.首先新建一个Web工程
2.添加Struts框架1.2版本
3.添加Spring框架2.0版本,选择拷贝其中的类库到lib文件夹下
4.添加Hibernate框架3.1版本,选择拷贝其中的类库到lib文件夹下
5.删去类库中的asm-2.2.3.jar文件
6.最后就能成功运行
struts-config.xml<?xml version="1.0" encoding="UTF-8"?>
<!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="insertForm" type="com.yourcompany.struts.form.InsertForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action attribute="insertForm" input="/insert.jsp" name="insertForm" path="/insert" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="ok" path="/ok.jsp" />
</action>
</action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean name="/insert" class="com.yourcompany.struts.action.InsertAction" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
<property name="testDAO">
<ref bean="TestDAO" />
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/test"></property>
<property name="username" value="root"></property>
<property name="password" value="123456"></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>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yourcompany/hibernate/Test.hbm.xml</value>
</list>
</property>
</bean>
<bean id="TestDAO" class="com.yourcompany.hibernate.TestDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
久久不醉