In the Struts documentation, it says:
Another common workflow stategy is to first render a page using an alternate method, like input and then have it submit back to the default execute method.
How to do it using annotation only? It seems that only the execute()
method is called.
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 theinput
result. Usually it happens automatically during validation process if the validation fails or ithasErrors
. Then you can submit the form back to the default action'sexecute
method. You don't need to specify amethod
in the action configuration. Also if you didn't specify theaction
attribute in theform
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 usingGET
method andinput
whenPOST
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.