架構與耦合-Strust2 使用設定檔管理常量

來源:互聯網
上載者:User

架構與耦合-Strust2 使用設定檔管理常量

struts2 常量也叫Struts2屬性,用來控制整個Struts2的應用特性。 1、Struts2常量配置有三種方式:
    (1)在web.xml中:每個常量配置需要4行
        <!-- 通過Filter配置初始化參數,就可配置Struts2的常量-->
        <init-param>
            <param-name>name</param-name>
            <param-value>value</param-value>
        </init-param>

    (2)在struts.xml檔案配置,每行配置一個常量
        <constant name="name" value="value"/>

    (3)額外增加一個struts.properties檔案,每行配置一個常量
        name=value

2、Struts2支援的常用的幾個常量
    (1)struts.i18n.encoding -等同於request.setCharacterEncoding("utf-8")
    (2)struts.multipart.saveDir -設定檔案上傳的臨時目錄
    (3)struts.multipart.maxsize -設定每次請求上傳的檔案總大小不能超過該大小
    (4)struts.action.extension  -設定Action預設的尾碼。該常量的預設值是action
    (5)struts.serve.static.browserCache - 控制瀏覽器是否緩衝靜態內容。
    (6)struts.devMode -設定是否處於開發模式
        等同於以下兩個配置
        struts.i18n.relode -設定是否每次請求都重新載入資源檔。開發階段設定為true
        struts.configration.xml.relode -設定每次struts.xml修改之後,應用自動重新載入
    (7)struts.custom.i18n.resource -載入國際化資源檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.