In the documentation it's said to render a page can be used an alternate method like input
. This means that when you submit a form on the page it can return back with the input
result. Usually it happens automatically during validation process if the validation fails or it hasErrors
. Then you can submit the form back to the default action's execute
method. You don't need to specify a method
in the action configuration. Also if you didn't specify the action
attribute in the form
tag then the same action will execute which was used to render a page.
Configuring actions you can use the same page for success
result when rendering a page using GET
method and input
when POST
method is requested.
To use annotations to configure actions mapping you can use a Convention Plugin.
Also note, to map a class method to the action you should put @Action
annotation directly on this method rather than on the class.
More detailed explanation and documentation you can find here.
@Namespace("/")
public class ProductAction extends ActionSupport {
public String execute() {
return SUCCESS;
}
@Action(value="product",
results=@Result(location="/product-list.jsp")
)
public String search() {
return SUCCESS;
}
}
Notice, that the method execute
is not mapped, so it will not execute. If you need that method execute you should create mapping to it. For this purpose you could place annotation on class or on method execute
.