web.xml

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
  3.  
  4.     <display-name>Struts Blank</display-name> 
  5.  
  6.     <filter> 
  7.         <filter-name>struts2</filter-name> 
  8.         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
  9.     </filter> 
  10.  
  11.     <filter-mapping> 
  12.         <filter-name>struts2</filter-name> 
  13.         <url-pattern>/*</url-pattern> 
  14.     </filter-mapping> 
  15.  
  16.     <welcome-file-list> 
  17.         <welcome-file>index.html</welcome-file> 
  18.     </welcome-file-list> 
  19.  
  20. </web-app> 

 

struts.xml

  1. <?xml version="1.0" encoding="UTF-8" ?> 
  2. <!DOCTYPE struts PUBLIC 
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd"> 
  5.  
  6. <struts> 
  7.  
  8.     <constant name="struts.enable.DynamicMethodInvocation" value="false" /> 
  9.     <constant name="struts.devMode" value="false" /> 
  10.  
  11.     <include file="example.xml"/> 
  12.  
  13.  
  14.  
  15.     <package name="default" namespace="/" extends="struts-default"> 
  16.         <default-action-ref name="index" /> 
  17.         <action name="index"> 
  18.             <result type="redirectAction"> 
  19.                 <param name="actionName">HelloWorld</param> 
  20.                 <param name="namespace">/example</param> 
  21.             </result> 
  22.         </action> 
  23.     </package> 
  24.  
  25.     <!-- Add packages here --> 
  26.  
  27. </struts> 

 

 

example.xml

 

  1. <?xml version="1.0" encoding="UTF-8" ?> 
  2. <!DOCTYPE struts PUBLIC 
  3.         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
  4.         "http://struts.apache.org/dtds/struts-2.0.dtd"> 
  5.  
  6. <struts> 
  7.  
  8.     <package name="example" namespace="/example" extends="struts-default"> 
  9.  
  10.         <action name="HelloWorld" class="example.HelloWorld"> 
  11.             <result>/example/HelloWorld.jsp</result> 
  12.         </action> 
  13.  
  14.         <action name="Login_*" method="{1}" class="example.Login"> 
  15.             <result name="input">/example/Login.jsp</result> 
  16.             <result type="redirectAction">Menu</result> 
  17.         </action> 
  18.  
  19.         <action name="*" class="example.ExampleSupport"> 
  20.             <result>/example/{1}.jsp</result> 
  21.         </action> 
  22.  
  23.         <!-- Add actions here --> 
  24.     </package> 
  25. </struts>