[
https://issues.apache.org/jira/browse/WW-3717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart updated WW-3717:
------------------------------
Description:
Allow an action declared in {{struts.xml}} to restrict which HTTP methods it
accepts, using a new optional {{http-method}} attribute in the 7.5 DTD. This is
the XML counterpart of the existing {{@HttpGet}} / {{@HttpPost}} /
{{@AllowedHttpMethod}} annotations.
{code:xml}<action name="action1" class="org.example.ListAction"
http-method="get"> ...
<action name="action2" class="org.example.SaveAction" http-method="post"> ...
<action name="action3" class="org.example.FormAction" http-method="get,post">
...
{code}
A request using a method that is not listed is rejected by
{{HttpMethodInterceptor}} with its configured bad-request result, the same way
as for the annotations.
Scope:
* one action name maps to one action config; declaring the same action name
twice with different methods is *not* supported here
* enforced by {{HttpMethodInterceptor}}, which reads the action config in
addition to the annotations; when both are present the request must satisfy both
* the attribute is carried over to actions resolved from wildcard / regex
patterns
* an invalid method name fails configuration loading
Routing the same action name to different action configs depending on the HTTP
method is tracked separately for 8.0.0.
was:
Struts action configuration (and dispatcher) should allow discrimination of
actions based on the HTTP method. This would allow generic REST style
interfaces (in excess of the rest plugin).
e.g.
{code:xml}
<action name="action1" http-method="get"> ...
<action name="action1" http-method="post"> ...
{code}
This is helpful when combined with regex patternmatcher for custom restful urls
e.g.
{code:xml}
<action name="/{entity:\w+}/{id:\d+}/{report:\w+}" http-method="get">
{code}
> Allow restricting an action to HTTP methods via an http-method attribute in
> struts.xml
> --------------------------------------------------------------------------------------
>
> Key: WW-3717
> URL: https://issues.apache.org/jira/browse/WW-3717
> Project: Struts 2
> Issue Type: New Feature
> Components: Dispatch Filter, XML Configuration
> Environment: All
> Reporter: Jeremy Norman
> Priority: Major
> Labels: restful
> Fix For: 7.5.0
>
>
> Allow an action declared in {{struts.xml}} to restrict which HTTP methods it
> accepts, using a new optional {{http-method}} attribute in the 7.5 DTD. This
> is the XML counterpart of the existing {{@HttpGet}} / {{@HttpPost}} /
> {{@AllowedHttpMethod}} annotations.
> {code:xml}<action name="action1" class="org.example.ListAction"
> http-method="get"> ...
> <action name="action2" class="org.example.SaveAction" http-method="post"> ...
> <action name="action3" class="org.example.FormAction" http-method="get,post">
> ...
> {code}
> A request using a method that is not listed is rejected by
> {{HttpMethodInterceptor}} with its configured bad-request result, the same
> way as for the annotations.
> Scope:
> * one action name maps to one action config; declaring the same action name
> twice with different methods is *not* supported here
> * enforced by {{HttpMethodInterceptor}}, which reads the action config in
> addition to the annotations; when both are present the request must satisfy
> both
> * the attribute is carried over to actions resolved from wildcard / regex
> patterns
> * an invalid method name fails configuration loading
> Routing the same action name to different action configs depending on the
> HTTP method is tracked separately for 8.0.0.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)