2

struts2 では、アクション名にスペースを含めることはできますか?

RegexPatternMatcher を使用しています

<constant name="struts.patternMatcher" value="regex"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>

私の行動は次のように定義されます

<action name="/users/{username}"
        method="execute"
        class="com.test.UserAction">
    <result name="success" type="tiles">.test.user</result>
</action>

のようなURLを試してみると、http://localhost:8080/users/a%20space a%20space がモデルのaspaceとして設定されています。%20 はエスケープされず、単に削除されます。私も試しましhttp://localhost:8080/users/a+spaceたが、同じことが起こります。

環境 Struts2 バージョン、2.3.15.1

4

1 に答える 1

0

struts 構成でパラメーターを設定することにより、アクション名にスペースを許可できます。

struts.allowed.action.names

デフォルトは

[a-zA-Z0-9._!/\-]*

DefaultActionMapper は、この正規表現を使用してアクション名を検証します。一致しない場合は、クリーンアップを試みます。

そのため、設定を次のように変更します

<constant name="struts.allowed.action.names" value="[ a-zA-Z0-9._!/\-]*"/>

スペースを許可する

于 2013-08-22T15:20:37.067 に答える