THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- The container receives from the web server a request for the resource
hello.action
. According to the settings loaded from the web.xml, the container finds that all requests are being routed toorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
, including the*.action
requests. The StrutsPrepareAndExecuteFilter is the entry point into the framework. - The framework looks for an action mapping named "hello", and it finds that this mapping corresponds to the class "HelloWorldAction". The framework instantiates the Action and calls the Action's
execute
method. - The
execute
method creates the MessageStore object and returnsSUCCESS
. The framework checks the action mapping to see what page to load ifSUCCESS
is returned. The framework tells the container to render as the response to the request, the resourceHelloWorld.jsp
. - As the page
HelloWorld.jsp
is being processed, the<s:property value="messageStore.message" />
tag calls the gettergetMessageStore
of theHelloWorld
Action and then calls thegetMessage
of the MessageStore object returned bygetMessageStore
, and the tag merges into the response the value of the message attribute. - A pure HTML response is sent back to the browser.
For detailed information on Struts 2 architecture see Why Struts 2.
What to Remember
The framework uses Actions to process HTML forms and other requests. The Action
class returns a result-name such as SUCCESS
, ERROR
, or INPUT
. Based on the mappings loaded from the struts.xml
, a given result-name may select a page (as in this example), another action, or some other web resource (image, PDF).
...