@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Action
A controller class's exposed methods are annotated with this annotation to flag them as action methods. A request always invokes a controller action method (unless it is intercepted by an interceptor). It's value is the value of the action parameter sent in the request. It's value is optional. If no value is specified, the method's name will be used as its value.
As an example, consider the following method (we'll assume it is declared in the context of a controller class, called "some-controller"):
@Action public View sayHello() { return new JSP("hello"); }
We can invoke this method by making the following request:
http://.../some-controller/sayHello
If we provide a value to the annotation, then we specify the name of action that is referred to in the request parameter:
@Action("say-hello") public View sayHello() { return new JSP("hello"); }
We can invoke the above method by making the following request:
http://.../some-controller/say-hello
A method annotated with this annotation must be public. It must also return a View. If it does not, the application will throw an Exception during the initialization of the application in the servlet container. An Exception will also be thrown if it returns a null View.
Action methods can also accept parameters. Please see Param
for more
information.
public abstract String value
Copyright © 2011-2012 MojaveMVC.org