Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Annotations > Before Annotation

Before Annotation

Marks a action method that needs to be executed before the main action method.

Usage

The Before annotation can be applied at method level.

Parameters

Parameter Required Default Notes
priority no 10 Priority order of method execution

Examples

public class SampleAction extends ActionSupport {

 @Before
 public void isAuthorized() throws AuthenticationException {
   // authorize request, throw exception if failed
 }

 public String execute() {
    // perform secure action
    return SUCCESS;
 }
}