不用配置Action和Result的struts.xml設定檔

來源:互聯網
上載者:User

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
        "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
 <!-- 上傳檔案大小限制 --> 
 <constant name="struts.multipart.maxSize" value="50971520" />
 <constant name="struts.devMode" value="true" />
 <!-- Convention預設所有的結果頁面都儲存在WEB-INF/content下,設定struts.convention.result.path的值到一個新的路徑
 如<constant name="struts.convention.result.path" value="/WEB-INF/jsp" /> -->

 <!--convention預設的根packages 有 struts, struts2, action, actions
  設定struts.convention.package.locators 用來更改Convention預設的根packages;
  設定struts.convention.action.packages. 來讓Convention只搜尋特定package下的Action
  -->
 <constant name="struts.convention.default.parent.package" value="crud-default" />
 <constant name="struts.devMode" value="true" />
 
 <!-- 用於CRUD Action的parent package -->
 <package name="crud-default" extends="convention-default">
  <!-- 基於paramsPrepareParamsStack,增加store interceptor保證actionMessage在redirect後不會丟失 -->
  <interceptors>
   <interceptor-stack name="crudStack">
    <interceptor-ref name="store">
     <param name="operationMode">AUTOMATIC</param>
    </interceptor-ref>
    <interceptor-ref name="paramsPrepareParamsStack" />
   </interceptor-stack>
  </interceptors>
  
  <default-interceptor-ref name="crudStack" />
 </package>

 <!--使用Convention外掛程式,實現約定大於配置的零設定檔風格.特殊的Result路徑在Action類中使用@Result設定. -->
</struts>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.