各版本struts所需导入的包

struts-2.0 所必需的jar包

1.commons-logging----.jar

2.struts-core----.jar

3.xwork----.jar 

4.ognl----.jar

5.freemarker----.jar

 

struts-2.1.6 所必需的jar包

1.commons-fileupload----.jar

2.commons-logging----.jar

3.struts-core----.jar

4.xwork----.jar 

5.ognl----.jar

6.freemarker----.jar

 

struts-2.3.4.1所必需的

1.commons-fileupload----.jar

2.commons-logging----.jar

3.struts-core----.jar

4.xwork----.jar 

5.ognl----.jar

6.freemarker----.jar

7.commons-lang3----jar

8.javassist----.GA.jar

9.commons-io------.jar

10.commons-lang-----.jar

配置文件

web.xml配置文件

基本上只需配置一次剩下多是配置struts.xml

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <web-app version="3.0"  
  4.  
  5.     xmlns="http://java.sun.com/xml/ns/javaee"  
  6.  
  7.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  8.  
  9.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
  10.  
  11.     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
  12.  
  13.    
  14.  
  15.     <filter> 
  16.  
  17.         <filter-name>struts2</filter-name> 
  18.  
  19.         <filter-class>   
  20.  
  21.         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 
  22.  
  23.         </filter-class> 
  24.  
  25.     </filter> 
  26.  
  27.      
  28.  
  29.     <filter-mapping> 
  30.  
  31.         <filter-name>struts2</filter-name> 
  32.  
  33.         <url-pattern>/*</url-pattern> 
  34.  
  35.     </filter-mapping>   
  36.  
  37.    
  38.  
  39. </web-app> 

struts.xml

 

  1. <?xml version="1.0" encoding="UTF-8" ?> 
  2. <!DOCTYPE struts PUBLIC 
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" 
  4.     "http://struts.apache.org/dtds/struts-2.3.dtd"> 
  5.  
  6.      
  7.     <struts> 
  8.      
  9.         <package name="struts2" extends="struts-default"> 
  10.          
  11.             <action name="helloword" class="com.test.action.helloWorld"> 
  12.                 <result name="success">/helloworld.jsp</result> 
  13.             </action>  
  14.  
  15.         </package> 
  16.      
  17.  
  18.     </struts>