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

Lukasz Lenart commented on WW-3193:
-----------------------------------

Triaged against current {{main}} (7.4.0-SNAPSHOT).

The behaviour described is unchanged: the generated form URL takes its 
extension from the current request's {{ActionMapping}} before falling back to 
the default ({{DefaultActionMapper.lookupExtension}}). That rule is not 
specific to the form tag — the same method builds URLs for {{s:url}}, {{s:a}}, 
{{s:submit action=...}} and the {{redirectAction}} result — so an {{extension}} 
attribute on {{s:form}} alone would fix one surface and leave the others 
inheriting.

As noted on WW-4164, specifying the extension per package/action in the 
configuration covers all of those surfaces at once and also makes inbound 
matching canonical. Per the reporter's own comment there, this issue goes away 
with that approach. Closing this one as superseded by WW-4164; the design 
question moves there.

Workaround available today: a form {{action}} that already carries the 
extension (e.g. {{action="changeCar.action"}}) is emitted verbatim — see 
{{FormTagTest#testFormWithActionAndExtension}}. Note that the literal path does 
not resolve the action configuration, so the form logs a "No configuration 
found" warning and client-side validation is not generated for it.

> Form action always inherits parent extension
> --------------------------------------------
>
>                 Key: WW-3193
>                 URL: https://issues.apache.org/jira/browse/WW-3193
>             Project: Struts 2
>          Issue Type: Improvement
>    Affects Versions: 2.1.8
>            Reporter: Jasper Rosenberg
>            Priority: Minor
>             Fix For: 7.4.0
>
>         Attachments: WW-3193.patch
>
>
> Here is the basic issue.  I have an url that has no extension, eg. 
> /Overview-Mustang-c1234
> On that page, I have a form tag that I want to have submit to action 
> "changeCar.action", and so the "action" attribute is set to "changeCar".  
> This used to work.  However, task WW-2267 changed the behavior so that the 
> form's action gets the parent mapping's extension 
> [DefaultActionMapper.getUriFromActionMapping() called from 
> ServletUrlRenderer.renderFormUrl()], in this case the empty string, so the 
> generated action ends up as just "changeCar" rather than "changeCar.action"  
> Because we have some special handling for our mappings, this url ends up as a 
> 404.  It just doesn't seem desirable in general however that the same form 
> included on different pages with different extensions will generate posts to 
> two differently named urls.
> I understand the concept behind this change, but I wonder if it would be 
> safer to revert it, and instead add support for an attribute on the form 
> which is "extension" which if present overrides the default, but otherwise 
> the default is used.  Alternatively, it could be an mutli-value such as 
> "inherit" (new behavior), "default" (old behavior), or ".ext" (a specific 
> extension).  With the default value being "default" so as to maintain 
> backwards compatibility to the 2.0 branch.



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

Reply via email to