struts2_5_struts中常量的配置

來源:互聯網
上載者:User

標籤:struts   常量配置   

常量有兩種配置方式:

1)在struts.xml中配置:(建議使用此種配置方式)

<struts>  <constant name=”struts.action.extension” value=”action”/><struts>

2)在struts.properties中配置常量:

  truts.action.extension = action

因為常量可以在下面多設定檔中進行定義,所以我們需要瞭解struts2載入常量的搜尋順序:

struts-default.xml

struts-plugin.xml

struts.xml

struts.properties

web.xml

如果在多個檔案中配置了同一個常量,則後一個檔案中配置的常量值會覆蓋前面檔案中配置的常量值。

常用的常量介紹:

1)指定編碼集:

<constant name=”struts.i18n.encoding” value=”UTF-8”>

2)指定struts2請求處理的尾碼:

該屬性的預設值是Action,即所有匹配“*.action”的請求都由Struts2處理,如果需要指定多個尾碼,則多個尾碼之間用逗號”,“分隔開

<span style="font-size:12px;"><constant name=”struts.action.extension” value=”do,action”/></span>

3)xml檔案自動重新載入:

該檔案當struts被檔案修改後,系統會自動重新載入該檔案,預設值為false,開發階段最好設定為true,

<span style="font-size:12px;"><constant name=”struts.configuration.xml.reload” value=”true”/></span>

4)列印錯誤資訊的常量:

次常量在開發模式下使用,會列印出更詳細的錯誤資訊

<constant name=”strus.devMode” value=”true”/>

5)struts支援動態屬性:

該屬性設定struts是否支援動態屬性,該屬性的預設值是true,關閉該屬性時可以設定為false,

<constant name=”struts.enable.DynamicMethodInvocation” value=”false”/>

6)管理上傳檔案大小的常量:

該屬性可以設定上傳檔案的大小

<constant name="struts.multipart.maxSize" value="1000000"/>










聯繫我們

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