spring,struts1,hibernate调整

spring,struts1,hibernate整合

1. 创建一个web项目,添加struts Capabilities


2. 加入spring的jar包


3. 在WEB-INF目录下,添加spring的配置文件。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd ">

<beans >
 
</beans>


4. 在web.xml中加入spring的监听器

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

 

5. 修改struts的配置文件,将action类改为org.springframework.web.struts.DelegatingActionProxy

<action input="/index.jsp" path="/login" type="org.springframework.web.struts.DelegatingActionProxy" name="loginForm" validate="true">
          <forward name="welcome" path="/welcome.jsp"></forward>
          <forward name="fail" path="/index.jsp"></forward>
 </action>

 

6.在spring的配置文件中添加action bean,将bean的name属性设置为path属性的值

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans >
    <bean name="/login" class="com.aowin.action.LoginAction"></bean>
</beans>