This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch release/struts-6-8-x
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/release/struts-6-8-x by this
push:
new 0c4762791 WW-2963 fix(core): resolve default-action-ref via wildcard
matching (#1623)
0c4762791 is described below
commit 0c476279108c4b7c383c2554c84ac4a9065bf0d9
Author: Lukasz Lenart <[email protected]>
AuthorDate: Mon Mar 16 07:25:30 2026 +0100
WW-2963 fix(core): resolve default-action-ref via wildcard matching (#1623)
When a default-action-ref points to an action name that only exists as a
wildcard pattern (e.g. "movie-input" matching "movie-*"), the framework
now falls back to wildcard matching after the exact lookup fails.
Port of PR #1614 from Struts 7 to Struts 6.x.
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../xwork2/config/impl/DefaultConfiguration.java | 3 +++
.../xwork2/config/ConfigurationTest.java | 20 ++++++++++++++++++++
core/src/test/resources/xwork-sample.xml | 21 +++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
index a2f73879d..b821f7f88 100644
---
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
+++
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
@@ -622,6 +622,9 @@ public class DefaultConfiguration implements Configuration {
String defaultActionRef =
namespaceConfigs.get(namespace);
if (defaultActionRef != null) {
config = actions.get(defaultActionRef);
+ if (config == null) {
+ config =
namespaceActionConfigMatchers.get(namespace).match(defaultActionRef);
+ }
}
}
}
diff --git
a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java
b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java
index 520f8c240..d23407b9e 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/ConfigurationTest.java
@@ -338,6 +338,26 @@ public class ConfigurationTest extends XWorkTestCase {
}
+ public void testDefaultActionRefWithWildcard() {
+ RuntimeConfiguration runtimeConfiguration =
configurationManager.getConfiguration().getRuntimeConfiguration();
+ ActionConfig config =
runtimeConfiguration.getActionConfig("/wildcard-default", "unmatchedAction");
+ assertNotNull("Wildcard default action ref should resolve via wildcard
matching", config);
+ assertEquals("com.opensymphony.xwork2.SimpleAction",
config.getClassName());
+ }
+
+ public void testDefaultActionRefWithExactMatch() {
+ RuntimeConfiguration runtimeConfiguration =
configurationManager.getConfiguration().getRuntimeConfiguration();
+ ActionConfig config =
runtimeConfiguration.getActionConfig("/exact-default", "unmatchedAction");
+ assertNotNull("Exact default action ref should resolve via exact
matching", config);
+ assertEquals("com.opensymphony.xwork2.SimpleAction",
config.getClassName());
+ }
+
+ public void testDefaultActionRefWithWildcardNoMatch() {
+ RuntimeConfiguration runtimeConfiguration =
configurationManager.getConfiguration().getRuntimeConfiguration();
+ ActionConfig config =
runtimeConfiguration.getActionConfig("/wildcard-default-nomatch",
"unmatchedAction");
+ assertNull("Default action ref with no matching action should return
null", config);
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
diff --git a/core/src/test/resources/xwork-sample.xml
b/core/src/test/resources/xwork-sample.xml
index 4e62f4c12..c2b17e154 100644
--- a/core/src/test/resources/xwork-sample.xml
+++ b/core/src/test/resources/xwork-sample.xml
@@ -295,5 +295,26 @@
<!-- default-class-ref is expected to be inherited -->
</package>
+ <package name="wildcardDefault" extends="default"
namespace="/wildcard-default">
+ <default-action-ref name="movie-input" />
+ <action name="movie-*" class="com.opensymphony.xwork2.SimpleAction">
+ <result name="success" type="mock">/movie/{1}.jsp</result>
+ </action>
+ </package>
+
+ <package name="exactDefault" extends="default" namespace="/exact-default">
+ <default-action-ref name="home" />
+ <action name="home" class="com.opensymphony.xwork2.SimpleAction">
+ <result name="success" type="mock">/home.jsp</result>
+ </action>
+ </package>
+
+ <package name="wildcardDefaultNoMatch" extends="default"
namespace="/wildcard-default-nomatch">
+ <default-action-ref name="nonExistentAction" />
+ <action name="movie-*" class="com.opensymphony.xwork2.SimpleAction">
+ <result name="success" type="mock">/movie/{1}.jsp</result>
+ </action>
+ </package>
+
<include file="includeTest.xml"/>
</struts>