This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/main by this push:
new 894540128 WW-3226 docs: explain how alias and params ordering decides
which value wins (#329)
894540128 is described below
commit 8945401288bed9fef8d5983198eddf38555c4952
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Sep 12 10:08:02 2026 +0200
WW-3226 docs: explain how alias and params ordering decides which value
wins (#329)
The alias interceptor page never said what happens when a request carries
both the source name and the alias target, and its own example puts alias
before basicStack, where the directly submitted parameter silently wins.
Document the ordering rule and the params-then-alias stack that makes the
alias override, which is the behavior WW-3226 asked an overwrite flag for.
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
source/core-developers/alias-interceptor.md | 32 ++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/source/core-developers/alias-interceptor.md
b/source/core-developers/alias-interceptor.md
index 1940fc9df..1be9c17c4 100644
--- a/source/core-developers/alias-interceptor.md
+++ b/source/core-developers/alias-interceptor.md
@@ -17,7 +17,37 @@ is applied to has a setter named `alias1`, `alias1` will be
set with the value f
## Parameters
- - `aliasesKey` (optional) - the name of the action parameter to look for the
alias map (by default this is aliases
+ - `aliasesKey` (optional) - the name of the action parameter to look for the
alias map (by default this is `aliases`)
+
+## Ordering relative to the `params` interceptor
+
+The interceptor sets the aliased property on the action at the moment it runs,
and so does the `params` interceptor.
+When a request carries both the source name and the target name, whichever of
the two interceptors runs last wins:
+
+| Stack order | Request `foo=1&bar=2`, aliases `#{ 'foo' : 'bar' }` | `bar`
after both have run |
+|---|---|---|
+| `alias` before `params` (the `defaultStack` order) | `alias` sets `bar=1`,
then `params` sets `bar=2` | `2` — the directly submitted parameter wins |
+| `params` before `alias` | `params` sets `bar=2`, then `alias` sets `bar=1` |
`1` — the alias overrides the submitted parameter |
+
+To make the alias override a directly submitted parameter, place `alias` after
`params` in a custom stack. Keep it
+before `conversionError` so that a conversion failure while binding the
aliased property still becomes a field error:
+
+```xml
+<interceptor-stack name="aliasOverridesStack">
+ <interceptor-ref name="exception"/>
+ <interceptor-ref name="servletConfig"/>
+ <interceptor-ref name="i18n"/>
+ <interceptor-ref name="staticParams"/>
+ <interceptor-ref name="actionMappingParams"/>
+ <interceptor-ref name="params"/>
+ <interceptor-ref name="alias"/>
+ <interceptor-ref name="conversionError"/>
+ <interceptor-ref name="validation"/>
+ <interceptor-ref name="workflow"/>
+</interceptor-stack>
+```
+
+There is no `overwrite` flag on this interceptor; the ordering above is the
supported way to get that behavior.
## Extending the Interceptor