You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Boris Kole (Jira)" <ji...@apache.org> on 2025/01/19 16:34:00 UTC

[jira] [Commented] (WW-4366) Action methods should accept arguments like @QueryParam, @FormParam, @PathParam and specific request methods GET, PUT, POST etc

    [ https://issues.apache.org/jira/browse/WW-4366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17914472#comment-17914472 ] 

Boris Kole commented on WW-4366:
--------------------------------

[~lukaszlenart],
I noticed that this issue is referenced in the 7.0.0-M1 release notes, but it seems it hasn’t been completed yet. Is this a mistake or am I missing something?

[Version Notes 7.0.0-M1 - Apache Struts 2 Wiki - Apache Software Foundation|https://cwiki.apache.org/confluence/display/WW/Version+Notes+7.0.0-M1]
!image-2025-01-19-17-30-56-571.png|width=702,height=180!

> Action methods should accept arguments like  @QueryParam, @FormParam, @PathParam and specific request methods GET, PUT, POST  etc
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-4366
>                 URL: https://issues.apache.org/jira/browse/WW-4366
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Core Actions
>            Reporter: samarjit samanta
>            Priority: Major
>              Labels: features
>             Fix For: 7.1.0
>
>         Attachments: image-2025-01-19-17-30-56-571.png
>
>
> Struts2 action methods should accept arguments just like JAX-RS specs. Also certain method types should be allowed only like GET, PUT, POST, DELTE. 
> Inspiration might be taken from struts-json plugin @SMDMthod but that is not a real action method. 
> If there are multiple action methods in a Action class then it becomes less obvious which variables are used for a particular action method. 
> Ex.
> {code:java}
>     @ActionPath("/books/{id}")
>     public String showAction(@PathParam("id") String id,
>                                             @QueryParam("name") String name) {
> 		...
> 		return "success";
>     }
> {code}
> Also flexible return types as defined in JAX-RS would be great or atleast 
> {code:java}
> Result.json(myObject).includeActionErrors().includeActionMessages().done();
> Result.string(myString).done();
> Result.create("json").from(myObject).param("includeActionErrors,includeActionMessages").done();
> {code}
> The action method return type can be to denote builder like result. The closest in struts I can see is HttpHeaderResult. But this does not allow arbritrary string result and let the end user create the string as json or plain text. 
> {code:java}
>    @Action
>    public Result showAction(...){}
> {code}
> Inspiration can be taken from struts2-json-plugin#SMDMethod and https://github.com/bastengao/struts2-freeroute



--
This message was sent by Atlassian Jira
(v8.20.10#820010)