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

ssh框架整合难点
——web.xml--

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

  
  <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  <init-param>
  <param-name>config</param-name>
  <param-value>/WEB-INF/struts-config.xml</param-value>
  </init-param>
  <init-param>
  <param-name>debug</param-name>
  <param-value>3</param-value>
  </init-param>
  <init-param>
  <param-name>detail</param-name>
  <param-value>3</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
  <welcome-file>getusers.jsp</welcome-file>
  </welcome-file-list>
</web-app>
————————————————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>
  <form-beans >
  <form-bean name="getusersForm" type="org.apache.struts.action.DynaActionForm">
  <form-property name="password" type="java.lang.String" />
  <form-property name="adress" type="java.lang.String" />
  <form-property name="email" type="java.lang.String" />
  <form-property name="usernamr" type="java.lang.String" />
  <form-property name="tel" type="java.lang.String" />
  </form-bean>

  </form-beans>

  <global-exceptions />
  <global-forwards >
  <forward
  name="success"
  path="/display.jsp"
  redirect="true" />

  </global-forwards>

  <action-mappings >
  <action
  attribute="getusersForm"
  input="/getusers.jsp"
  name="getusersForm"
  path="/getusers"
  scope="request"
  type="org.springframework.web.struts.DelegatingActionProxy" />

  </action-mappings>

  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml"/>