You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2025/10/17 09:58:38 UTC
(struts-site) 01/01: docs: Add validation file naming documentation for actions with slashes
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch docs/validation-slash-naming
in repository https://gitbox.apache.org/repos/asf/struts-site.git
commit bdca71c39a2856bc0c13f8de8746e2e2bc73cd1e
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Fri Oct 17 11:58:13 2025 +0200
docs: Add validation file naming documentation for actions with slashes
- Add detailed explanation of slash-to-hyphen replacement rule in core validation docs
- Include concrete example: a/b/myaction.validate -> MyAction-a-b-myaction.validate-validation.xml
- Reference AnnotationActionValidatorManager implementation
- Add cross-references in getting started tutorial and action configuration docs
- Addresses gap in documentation for struts.enable.SlashesInActionNames usage
Fixes validation file naming confusion when using slashes in action names.
---
source/core-developers/action-configuration.md | 2 ++
source/core-developers/validation.md | 27 ++++++++++++++++++++++
.../getting-started/form-validation-using-xml.md | 2 ++
3 files changed, 31 insertions(+)
diff --git a/source/core-developers/action-configuration.md b/source/core-developers/action-configuration.md
index 45e63c8d4..26a7e2b97 100644
--- a/source/core-developers/action-configuration.md
+++ b/source/core-developers/action-configuration.md
@@ -77,6 +77,8 @@ to specifically allow slashes in your action names via a constant in the `struts
See [JIRA Issue WW-1383](https://issues.apache.org/jira/browse/WW-1383) for discussion as there are side effects
to setting this property to `true`.
+> **Note:** When using slashes in action names, validation file naming requires special attention. Slashes in action aliases are replaced with hyphens in validation file names. See [Validation Files for Actions with Slashes](validation#validation-files-for-actions-with-slashes) for detailed information.
+
__Action Names with Dots and Dashes__
Although action naming is pretty flexible, one should pay attention when using dots (eg. create.user) and/or dashes
diff --git a/source/core-developers/validation.md b/source/core-developers/validation.md
index 2c31f52b6..122dad433 100644
--- a/source/core-developers/validation.md
+++ b/source/core-developers/validation.md
@@ -144,6 +144,33 @@ Validation rules can be specified:
XWork searches up the inheritance tree of the action to find default
validations for parent classes of the Action and interfaces implemented
+### Validation Files for Actions with Slashes
+
+When using action names with slashes (enabled via `struts.enable.SlashesInActionNames`), the validation file naming follows a special rule: **slashes in the action alias are replaced with hyphens**.
+
+**Pattern:** `ClassName-{action-alias-with-slashes-replaced-by-hyphens}-validation.xml`
+
+**Example:**
+
+For this action configuration:
+```xml
+<constant name="struts.enable.SlashesInActionNames" value="true"/>
+
+<action name="a/b/myaction.validate"
+ class="myPath.MyAction"
+ method="create">
+ <result name="input" type="tiles">mytiles</result>
+</action>
+```
+
+The validation file should be named:
+- **Action-specific alias validation:** `MyAction-a-b-myaction.validate-validation.xml`
+- **General action validation:** `MyAction-validation.xml` (applies to all aliases)
+
+**Location:** Place validation files in `src/main/resources/myPath/` (following your package structure)
+
+This behavior is implemented in `AnnotationActionValidatorManager` where `context.replace('/', '-')` converts the action alias for file resolution.
+
Here is an example for SimpleAction-validation.xml:
```xml
diff --git a/source/getting-started/form-validation-using-xml.md b/source/getting-started/form-validation-using-xml.md
index 8845afd59..7803d8610 100644
--- a/source/getting-started/form-validation-using-xml.md
+++ b/source/getting-started/form-validation-using-xml.md
@@ -42,6 +42,8 @@ To validate a user's form field entries you can use a separate XML file that con
The XML file that contains the validation rules must be named as ActionClassName-validation.xml. In the example
application, the XML validation file is named EditAction-validation.xml (see src/main/resources/org/apache/struts/edit/action).
+> **Note:** When using action names with slashes (enabled via `struts.enable.SlashesInActionNames`), validation file naming follows a special rule where slashes are replaced with hyphens. See [Validation Files for Actions with Slashes](../core-developers/validation#validation-files-for-actions-with-slashes) for detailed information.
+
Struts provides several different validators that you can use in the XML validation file. See [Validation](../core-developers/validation)
for a list of validators you can employ.