ActionServlet workflow

The org.apache.struts.action.ActionServlet is the backbone of all Struts applications. It is the mainController component that handles client requests and determines which org.apache.struts.action.Action
will process each received request. It serves as an Action factory—creating specific Action classes based on the user's request.

When the ActionServlet receives a request, it completes the following steps:
1. The doPost() or doGet() methods receive a request and invoke the process() method.
The process() method gets the current RequestProcessor and invokes the RequestProcessor.process() method.

2.The process() method gets the current RequestProcessor and invokes the RequestProcessor.process() method.


3.The RequestProcessor.process() method is where the current request is actually serviced. This
method retrieves, from the struts-config.xml file, the <action> element that matches the path
submitted on the request. It does this by matching the path passed in the <html:form /> tag's action
element to the <action> element with the same path value. Here's an example of this match:
<html:form action="/Lookup" name="lookupForm" type="app.LookupForm" >


<action path="/Lookup"
              type="app.LookupAction"
              name="lookupForm" >
             <forward name="success" path="/quote.jsp"/>
             <forward name="failure" path="/index.jsp"/>
</action>

4.When the RequestProcessor.process() method has a matching <action>, it looks for a <form-bean>
entry that has a name attribute that matches the <action> element's name attribute. The following
code snippet contains a sample match:
<form-beans>
                      <form-bean name="lookupForm" type="app.LookupForm"/>
</form-beans>
<action path="/Lookup" type="app.LookupAction" name="lookupForm" >
            <forward name="success" path="/quote.jsp"/>
            <forward name="failure" path="/index.jsp"/>
</action>

5.When the RequestProcessor.process() method knows the fully qualified name of the FormBean, it
creates or retrieves a pooled instance of the ActionForm named by the <form-bean> element's type
attribute and populates its data members with the values submitted on the request.

6.After the ActionForm's data members are populated, the RequestProcessor.process() method calls
the ActionForm.validate() method, which checks the validity of the submitted values.

7.At this point, the RequestProcessor.process() method knows all that it needs to know and it is time
to actually service the request. It does this by retrieving the fully qualified name of the Action class
from the <action> element's type attribute, creating or retrieving the named class, and calling the Action.execute() method.

8.When the Action class returns from its processing, its execute() method returns an ActionForward object that is used to determine the target of this transaction. The RequestProcessor.process()
method resumes control, and the request is then forwarded to the determined target.

9.At this point, the ActionServlet instance has completed its processing for this request and is ready
to service future requests.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值