【Struts 2ラーニングノート(4)】Struts 2の処理が必要なリクエスト接尾辞およびディテール定数定義を指定する


一、Struts 2処理が必要な要求接尾辞を指定する
デフォルトでは.action接尾辞を使用してActionにアクセスしています.デフォルトの接尾辞は定数"struts.action.extension"で変更できます.たとえば、Struts 2は.doを接尾辞とするリクエストパスのみを処理するように構成できます.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.action.extension" value="do"/>
</struts>

ユーザーが複数のリクエスト接尾辞を指定する必要がある場合、複数の接尾辞は英語のカンマ(,)で区切られます.次のようになります.
 <constant name="struts.action.extension" value="do,go"/>

二、定数定義を詳しく述べる
(1)定数はstruts.xmlまたはstruts.propertiesで構成できます.struts.xmlで構成することをお勧めします.2つの構成方法は以下のとおりです.
1.struts.xmlファイルで定数を設定する
<struts>
    <constant name="struts.action.extension" value="do"/>
</struts>

2.struts.propertiesで定数を構成する
struts.action.extension=do

(2)定数は以下の複数のプロファイルで定義できるため、struts 2が定数をロードする検索順序を理解する必要があります.
struts-default.xml
struts-plugin.xml
struts.xml
struts.properties
web.xml
複数のファイルに同じ定数が設定場合、後のファイルで構成する定数値は、前のファイルで構成する定数値を上書きします.
(3)よく使われる定数の紹介
<span style="font-size:14px;"><!--        ,   HttpServletRequest setCharacterEncoding    freemarker 、velocity    -->
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <!--        Struts 2       ,        action,     *.action     Struts2  。
                  ,            (,)  。 -->
    <constant name="struts.action.extension" value="do"/>
    <!--              ,    true(       ),         -->
    <constant name="struts.serve.static.browserCache" value="false"/>
    <!--  struts        ,             ,    false(       ),         -->
    <constant name="struts.configuration.xml.reload" value="true"/>
    <!--        ,                -->
    <constant name="struts.devMode" value="true" />
     <!--         -->
    <constant name="struts.ui.theme" value="simple" />
    <!–  spring   ,   spring  action      -->
    <constant name="struts.objectFactory" value="spring" />
 <!–     Struts 2          ,        true。            ,        false。 -->
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
 <!--         -->
<constant name="struts.multipart.maxSize" value=“10701096"/>
</span>