Struts 配置文件

 web.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 5          version="3.1">
 6     <filter>
 7         <filter-name>struts</filter-name>
 8         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 9     </filter>
10     <filter-mapping>
11         <filter-name>struts</filter-name>
12         <url-pattern>/*</url-pattern>
13     </filter-mapping>
14 </web-app>

 

 struts.xml

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 
  3 <!DOCTYPE struts PUBLIC
  4         "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  5         "http://struts.apache.org/dtds/struts-2.3.dtd">
  6 
  7 <struts>
  8         <constant name="struts.custom.i18n.resources" value="i18n"/>
  9         <constant name="struts.devMode" value="true"/><!--开发模式,用途,更好的提示错误-->
 10         <constant name="struts.multipart.maxSize" value="104857600"/>
 11 
 12         <package name="user" namespace="/" extends="struts-default">
 13                 <action name="checkCookie" class="userAction" method="getCookie">
 14                         <result>pages/login.jsp</result>
 15                 </action>
 16                 <action name="*User" class="userAction" method="{1}">
 17                         <result name="success">/pages/{1}Success.jsp</result>
 18                         <result name="input">/pages/{1}.jsp</result>
 19                         <result name="updateSuccess">/pages/loginSuccess.jsp</result>
 20                         <result name="error">/pages/error.jsp</result>
 21                 </action>
 22                 <action name="update*">
 23                         <result>/pages/update{1}.jsp</result>
 24                 </action>
 25                 <action name="uploadImg" class="userAction" method="updateImg">
 26                         <interceptor-ref name="defaultStack">
 27                                 <param name="fileUpload.maximumSize">10485760</param>
 28                                 <param name="fileUpload.allowedExtensions">bmp,png,gif,jpeg,jpg</param>
 29                         </interceptor-ref>
 30                         <result name="success">/pages/loginSuccess.jsp</result>
 31                         <result name="input">/pages/updateImg.jsp</result>
 32                         <result name="error">/pages/error.jsp</result>
 33                 </action>
 34                 <action name="showDetails">
 35                         <result type="redirectAction">showUserDetails</result><!--重定向到某个action-->
 36                 </action>
 37         </package>
 38         <package name="checkUser" namespace="/" extends="json-default">
 39                 <action name="check*" class="userAction" method="check{1}">
 40                         <result type="json"/>
 41                 </action>
 42         </package>
 43         <package name="userDetails" namespace="/" extends="struts-default">
 44                 <action name="*UserDetails" class="userDetailsAction" method="{1}Details">
 45                         <result name="success">/pages/userDetails/showUserDetails.jsp</result>
 46                         <result name="error">/pages/error.jsp</result>
 47                 </action>
 48                 <action name="updateUserDetails" class="userDetailsAction" method="updateDetails">
 49                         <result name="success">/pages/userDetails/showUserDetails.jsp</result>
 50                         <result name="error">/pages/error.jsp</result>
 51                 </action>
 52                 <action name="deleteUserDetails" class="userDetailsAction" method="deleteDetails">
 53                         <result name="success">/pages/userDetails/showUserDetails.jsp</result>
 54                         <result name="error">/pages/error.jsp</result>
 55                 </action>
 56                 <action name="queryDetailsByUserId" class="userDetailsAction" method="queryDetailsByUserId">
 57                         <result>/pages/userDetails/updateUserDetails.jsp</result>
 58                 </action>
 59         </package>
 60         <package name="goods" namespace="/" extends="struts-default">
 61                 <action name="showGoods" class="goodsAction" method="showGoods">
 62                         <result>pages/goods/showGoods.jsp</result>
 63                 </action>
 64                 <action name="showGoodDetails" class="goodsAction" method="showGoodDetails">
 65                         <result>pages/goods/showGoodDetails.jsp</result>
 66                 </action>
 67         </package>
 68         <package name="buyCar" namespace="/" extends="struts-default">
 69                 <action name="*BuyCar" class="buyCarAction" method="{1}BuyCar">
 70                         <result name="success">pages/buyCar/showBuyCar.jsp</result>
 71                         <result name="error">/pages/error.jsp</result>
 72                 </action>
 73                 <action name="addBuyCar" class="buyCarAction" method="addBuyCar">
 74                         <result name="success">/pages/buyCar/addBuyCarSuccess.jsp</result>
 75                         <result name="error">/pages/error.jsp</result>
 76                 </action>
 77                 <action name="makeBill" class="buyCarAction" method="makeBill">
 78                         <result name="success">pages/orders/showBill.jsp</result>
 79                         <result name="error">/pages/error.jsp</result>
 80                 </action>
 81         </package>
 82         <package name="updateBuyCarCount" namespace="/" extends="json-default">
 83                 <action name="updateBuyCarCount" class="buyCarAction" method="updateBuyCarCount">
 84                         <result type="json"/>
 85                 </action>
 86         </package>
 87         <package name="order" namespace="/" extends="struts-default">
 88                 <action name="showOrders" class="ordersAction" method="showOrders">
 89                         <result>pages/orders/showOrders.jsp</result>
 90                 </action>
 91                 <action name="addOrder" class="ordersAction" method="addOrder">
 92                         <result name="success">pages/orders/addOrderSuccess.jsp</result>
 93                         <result name="error">/pages/error.jsp</result>
 94                 </action>
 95                 <action name="deleteOrder" class="ordersAction" method="deleteOrder">
 96                         <result name="success">pages/orders/showOrders.jsp</result>
 97                         <result name="error">/pages/error.jsp</result>
 98                 </action>
 99         </package>
100         <package name="img" namespace="/" extends="struts-default">
101                 <action name="showImg" class="com.iotek.homework.actions.ImgAction" method="showImg">
102                         <result>pages/showImg.jsp</result>
103                 </action>
104                 <action name="*Img" class="com.iotek.homework.actions.ImgAction" method="{1}Img">
105                         <result type="stream"/>
106                 </action>
107         </package>
108 </struts>
View Code

 

posted @ 2017-04-12 15:15  Bob.Xie  阅读(167)  评论(0编辑  收藏  举报