Struts Learning Note2 --- ActionServlet

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.

  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="ch04.LookupForm" >

<action path="/Lookup"
  type="ch04.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="ch04.LookupForm"/>

</form-beans>

<action path="/Lookup"
  type="ch04.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.

 


 

Configuring the ActionServlet :

Parameter

Description

config

Names the context-relative path to the struts-config.xml file. The default location is in the /WEB-INF/struts-config.xml directory. (Optional)

config/${module}

Names the context-relative path to the struts-config.xml file associated with a particular Struts Module. (Optional)

convertNull

A boolean parameter used to simulate Struts 1.0x functionality when populating an ActionForm. When this parameter is set to true, numeric objects (java.lang.Integer, etc.) are initialized to null. If it is set to false, these objects are set to 0.

debug

Determines the debugging level for the ActionServlet. The default value is 0, which turns debugging off. (Optional)

detail

Sets the debug level for the Digester object, which is used during ActionServlet initialization. The default value is 0. (Optional)

multipartClass

Names the fully qualified class of the MultipartRequestHandler implementation to be used when file uploads are being processed. The default value is org.apache.struts.upload.DiskMultipartRequestHandler. (Optional)

validating

If set to true, tells the ActionServlet that we want to validate the strut-config.xml file against its DTD. While this parameter is optional, it is highly recommended and therefore the default is set to true.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值