Struts 2 allows an application to use Java 5 annotations as an alternative to XML and Java properties configuration in many places. This page serves as a reference for all annotations across the framework.
Action Annotations
Action annotations are available when you have Struts 2 scan your classpath for Actions, rather than specifying them individually in XML configuration.
Annotation | Description |
---|---|
Namespace Annotation | Overrides the namespace of an action |
ParentPackage Annotation | Defines an existing configuration package for the action's package to extend |
Result | Defines an Action Result |
Results | Defines multiple Results |
Warning | ||
---|---|---|
| ||
This is a work in progress and not yet finished! More complex examples will follow. For now, have a look at the unit tests within the xwork-tiger project path. |
...
Interceptor Annotations
To use these annotations, you have to specify the AnnotationWorkflowInterceptor to your interceptor stack.
...
If you want to use annotation based validation, you have to annotate the class or interface with Validation Annotation.
These are the standard validator annotations that come with XWork-tiger:
Annotation | Description |
---|---|
Checks if there are any conversion errors for a field. | |
Checks that a date field has a value within a specified range. | |
Checks that a double field has a value within a specified range. | |
Checks that a field is a valid e-mail address. | |
Validates an expression. | |
Uses an OGNL expression to perform its validator. | |
Checks that a numeric field has a value within a specified range. | |
Validates a regular expression for a field. | |
Checks that a field is non-null. | |
Checks that a String field is not empty. | |
Checks that a String field is of the right length. | |
| |
Checks that a field is a valid URL. | |
Marker annotation for validation at Type level. | |
Used to group validation annotations. | |
| |
Use this annotation for your custom validator types. |
Type Conversion Annotations
If the xwork-tigerjar is added to the classpathBy default, you will directly have type conversion support for Maps and Collections using generics.
...