-
The processMultipart() method is called. If the HttpServletRequest method is a POST and the contentType of the request starts with multipart/form-data, the standard request object is wrapped with a special version from the Struts framework that deals exclusively with multipart requests. If the request method is a GET or the contentType is not multipart, the original request is returned. Unless your application supports uploading files, you don't need to worry about multipart functionality in Struts.
-
The processPath() method is called to determine the path component from the URI for the request. Among other things, this information is used to select the appropriate Struts Action to invoke.
-
The processLocale() method is called to determine the locale of the user making the request and to store a Locale object into the user's HttpSession object. The locale isn't always obtained into the user's session—it depends on the locale attribute in the controller configuration element. See Chapter 4 for more details on the attributes of the controller element.
-
Determine the content type and optional encoding of the request by calling the processContent() method. The content type may be configured in the configuration settings and also overridden by the JSPs. The default content type is text/html.
-
The processNoCache() method is called to determine whether the noCache attribute is set to true. If it is, add the proper header parameters in the response object to prevent the pages from being cached in the browser. The header parameters include Pragma, Cache-Control, and Expires.
-
The processPreprocess() method is called next. It's a general-purpose preprocessing hook that, by default, just returns true. However, subclasses can override this method and perform conditional logic to decide whether to continue processing the request. Because this method gets called before an Action is invoked, this is a good place to validate whether the user contains a valid session. If this method returns true, processing of the request will continue. If it returns false, processing will stop. It's up to you to programmatically redirect or forward the request—the controller will assume that you are handling the request and will not send a response to the client.
-
Determine the ActionMapping for the request using the path information by calling the processMapping( ) method. If a mapping can't be found using the path information, an error response will be returned to the client.
-
Check to see if any security roles are configured for the Action by calling the processRoles( ) method. If there are roles configured, the isUserInRole() method is called on the request. If the user doesn't contain the necessary role, processing will end here and an appropriate error message will be returned to the client.
-
Call the processActionForm() method to determine whether an ActionForm is configured for the ActionMapping. If an ActionForm has been configured for the mapping, an attempt will be made to find an existing instance in the appropriate scope. Once an ActionForm is either found or created, it is stored within the proper scope using a key that is configured in the name attribute for the Action element.
-
The processPopulate() method is called next, and if an ActionForm is configured for the mapping, its properties are populated from the request parameter values. Before the properties are populated from the request, however, the reset() method is called on the ActionForm.
-
The processValidate() method is called, and if an ActionForm has been configured and the validate attribute is set to true for the action element, the validate() method is called. If the validate() method detects errors, it will store an ActionErrors object into the request scope, and the request automatically will be forwarded to the resource specified by the input attribute for the action mapping. If no errors were detected from the validate() method or there was no ActionForm for the action mapping, processing of the request continues. You can configure the controller element to interpret the input attributes as defined forwards. See Chapter 4 for more information on this feature.
-
Determine if a forward or an include attribute is configured for the action mapping. If so, call the forward() or include() method on the RequestDispatcher, depending on which one is configured. The processing of the request ends at this point if either one of these is configured. Otherwise, continue processing the request.
-
Call the processActionCreate() method to create or acquire an Action instance to process the request. An Action cache will be checked to see if the Action instance already has been created. If so, that instance will be used to process the request. Otherwise, a new instance will be created and stored into the cache.
-
Call the processActionPerform() method, which in turn calls the execute() method on the Action instance. The execute() call is wrapped with a try/catch block so that exceptions can be handled by the RequestProcessor.
-
Call the processActionForward() method and pass it the ActionForward object returned from the execute() method. The processActionForward() method determines whether a redirect or a forward should occur by checking with the ActionForward object, which in turn depends on the redirect attribute in the forward element.
RequestProcessor's process()
最新推荐文章于 2020-10-19 17:10:19 发布