Struts calls a lot of stuff before the action is executed. But it's configurable in struts.xml
. You can see the request flow of the action execution from this answer.
Internally Struts uses the ObjectFactory
to build all objects
defined by the configuration. See more about ObjectFactory
docs
or The Struts 2 Request Flow.
Constructors should have the default constructor or no-argument constructor, otherwise it won't be constructed. For detailed explanation about differences you can see Java default constructor.
You don't have to provide any constructors for your class, but you
must be careful when doing this. The compiler automatically provides a
no-argument, default constructor for any class without constructors.
This default constructor will call the no-argument constructor of the
superclass. In this situation, the compiler will complain if the
superclass doesn't have a no-argument constructor so you must verify
that it does. If your class has no explicit superclass, then it has an
implicit superclass of Object, which does have a no-argument
constructor.
The methods are called mostly by interceptors before the action is executed. The default interceptor stack is defaultStack
. It has a lot of functionality involved that is executed before the action. See this answer to get impression about default configuration.
Interceptors are invoked before the action execution. It's like a
pipeline that serves the request. Each of them invoked one after
another. When the last interceptor processed the action is executed.
What interceptors to invoke configured in the action configuration or
via annotations. For detail explanation of interceptors see docs.