struts2基本的运行机制

How the Code Works
Your browser sends to the web server a request for the URL http://localhost:8080/Hello_World_Struts2_Ant/hello.action.

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 to org.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 returns SUCCESS. The framework checks the action mapping to see what page to load if SUCCESS is returned. The framework tells the container to render as the response to the request, the resource HelloWorld.jsp.
As the page HelloWorld.jsp is being processed, the <s:property value="messageStore.message" /> tag calls the getter getMessageStore of the HelloWorld Action and then calls the getMessage of the MessageStore object returned by getMessageStore, and the tag merges into the response the value of the message attribute.
A pure HTML response is sent back to the browser

你可能感兴趣的:(struts2)