Strict Method Invocationであり、Struts 2.5以降ではデフォルトで有効になっています。 SMIとワイルドカードマッピングに関するドキュメントから
:あなたは<package>
ごとにそれを
When using wildcard mapping in actions' definitions SMI works in two ways:
- SMI is disabled - any wildcard will be substituted with the default RegEx, ie.:
<action name="Person*" method="perform*">
will be translated into allowedMethod = "regex:perform([A-Za-z0-9_$]*)"
.
- SMI is enabled - no wildcard substitution will happen, you must strictly define which methods can be accessed by annotations or
<allowed-method/>
tag.
無効にすることができます。
<package strict-method-invocation="false">
か、<allowed-methods>
タグを使用して、アクションごとに許可されているメソッド名を追加することができます。
<action name="*Application" class="x.ApplicationHandler" method="{1}">
<result name="input">/WEB-INF/application.jsp</result>
<result name="success" type="redirectAction">
<param name="actionName">browseApps</param>
</result>
<allowed-methods>firstMethod, secondMethod, thirdMethod</allowed-methods>
</action>
または、<global-allowed-methods>
タグを使用してパッケージごとに許可されるメソッド名を追加します。あなたは2.5
にDTDの定義を更新する必要がありstruts.xmlに上記のタグを使用するためには
<package extends="struts-default">
<global-allowed-methods>firstMethod, secondMethod, thirdMethod</global-allowed-methods>
</package>
NOTE。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
...
</struts>
アクションが許可されたアクションメソッドを指定することができますstruts2-convention-pluginで@AllowedMethods
注釈もあります。
This annotation can be used directly on Action classes or in the package-info.java
class in order to specify global allowed methods for all sub-packages.
これは既にAleksandrによって説明されているSMIのためです。メソッドが許可されていないと、メソッドが見つからない例外がスローされます。 "このメソッドは許可されていません"という例外をスローする方が良いかどうか、私は思っています。 –
はい、より意味のある例外がここで非常に役立つかもしれません。 – john
私はこのhttps://issues.apache.org/jira/browse/WW-4640をカバーする問題を登録しました –