Annotation types in Struts 2

The Struts2 framework scans Action class in classpath using Convention Plug-in. You can use annotations in action class for mapping rather than configuration file struts.xml.
The Convention Plug-in provides the Codebehind Plug-in and Zero Config plug-in with following features :
  • Action location by package naming conventions
  • Result (JSP, FreeMarker, etc) location by naming conventions
  • Class name to URL naming convention
  • Package name to namespace convention
  • Action name overrides using annotations
  • Interceptor overrides using annotations
  • Namespace overrides using annotations
  • Default action and result handling
Action Annotations
AnnotationDescription
Actions AnnotationGroup of @Action annotations, maps multiple URLs to the same action
Action AnnotationDefines the URL of an action
InterceptorRefs AnnotationGropup of @InterceptorRef annotations
InterceptorRef AnnotationInterceptor, or interceptor stack to be applied to at action
Results AnnotationGroup of @Result annotations
Result AnnotationDefines a result for an action
ParentPackage AnnotationSet the parent package of the actions (used to overwrite the default)
ExceptionMappingsGroup of @ExceptionMapping annotations
ExceptionMappingDefines an exception mapping

Validation Annotations

Examples on Annotations

Previous Next


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code