Strutsr source code interpretation

xiaoxiao2021-03-06  14

It is said that the source code is interpreted, in fact, I just opened my head, I have the opportunity to slow down.

HTML: Form

Org.apache.struts.action.actionServlet;

ActionServlet Extends httpservlet

Dogetdopost

process (request, response); {processor = getRequestProcessor (config); processor.process (request, response);} RequestProcessor not inherit any of class, only a repquest processor, logic encapsulation method public void process (HttpServletRequest request, HttpServletResponse Response) {// Package Request Request = ProcessMultiPart (Request); / * Details: protected httpservletRequest processMultipart (httpservletRequest request) {

if {return (request);} ( "POST" .equalsIgnoreCase (request.getMethod ())!) String contentType = request.getContentType ();! if ((contentType = null) && contentType.startsWith ( "multipart / form- Data ")) {Return (New MultipArtRequestWrapper (Request));} else {return (request);

} * / // identify the path component we will use to select a mapping string path = processpath (request, response); if (path == null) {return;} // begin can ignore if (log.isdebugebueNabled ()) {Log.debug ("Processing A '" Request.getMethod () "' for path '" PATH "");}

// select a local for the capital user if Requested ProcessLocale (Request, Response);

// set the content type and no-caching headers if Requested processcontent (request, response); processnocache (request, response);

(! ProcessPreprocess (request, response)) // General purpose preprocessing hook if {return;} this.processCachedMessages (request, response); // end ignored // Identify the mapping for this request ActionMapping mapping = processMapping (request, response, PATH); if (mapping == null) {return;} / * Detailed Path Find mapping * /// Check for Any Role Required to Perform this action if (! process, response, mapping) {Return;} // processing of the action form // process any ActionForm bean related to this request ActionForm form = processActionForm (request, response, mapping); / * find actionform protected ActionForm processActionForm by mapping (HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) {

// Create (if necessary) a form bean to use ActionForm instance = RequestUtils.createActionForm (request, mapping, moduleConfig, servlet); / * details ActionForm instance = lookupActionForm (request, attribute, mapping.getScope ()); if (instance ! = NULL & CANREUSEACTIONFORM (Instance, Config) {Return (Instance); otherwise returnization; * / if (instance == null) {return (null)

// Store the new instance in the appropriate scope if (log.isDebugEnabled ()) {log.debug ( "Storing ActionForm bean instance in scope '" mapping.getScope () "' under attribute key '" mapping.getAttribute () "'");} If ("request" .Equals (mapping.getscope ()) {request.getattribute (), instance);} else {httpsession session = request.getations (); Session.SetaTRibute (mapping.getattribute (), instance);} Return (Instance);

* / ProcessPopulate (Request, Response, Form, Mapping); / * Requestutils.Populate (form, mapping.getprefix (), mapping.getsuffix (), request);

* / If {return;} (processValidate (request, response, form, mapping)!) / * Protected boolean processValidate (HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws IOException, ServletException {

IF (form == null) {return (TRUE);} // WAS THIS Request cancelled? if (request.gettribute (globals.cancel_key)! = null) {if (log.isdebugeload ()) {Log.debug (" Cancelled Transaction, Skipping Validation ");} Return (True);

// Has Validation Been Turned Off for this mapping? If (! Mapping.getvalidate ()) {return (true);

// Call the form bean's validation method if (log.isDebugEnabled ()) {log.debug ( "Validating input form properties");} ActionMessages errors = form.validate (mapping, request); if ((errors == null) || Errors.iseMpty ()) {if (Log.IstraceNabled ()) {log.trace ("no errors detected, accepting");} Return (TRUE);} // Special Handling for Multipart Request if (Form. getMultipArtRequestHandler ()! = null) {if (Log.IstraceNabled ()) {log.trace ("Rolling Back Multipart Request");} form.getMultipartRequestHandler (). rollback ();

// Was an input path (or forward) specified for this mapping? String INPUT = mapping.getinput (); if (input == null) {if (log.Istracenabled ()) {log.trace ("Validation Failed But no Input form avilable ");} response.senderror (httpservletResponse.sc_internal_server_error, getinternal (). getMessage (" noInput ", mapping.getpath ()))); Return (false);}

// save ire messages and return to the input form if Possible if (Log.IndebuGenabled ()) {log.debug ("Validation Failed, Returning to '" Input "");} Request.setttribute (Globals. Error_Key, Errors);

if (. moduleConfig.getControllerConfig () getInputForward ()) {ForwardConfig forward = mapping.findForward (input); processForwardConfig (request, response, forward);} else {internalModuleRelativeForward (input, request, response);} return (false);

}

* /

// process a forward or include specified by this mappingiff (! Process,}) {return;}}}}}} {Return;}

// Create or acquire the action instance to process this request action action = processActioncreate (request, response, mapping); if (action == null) {return;}

// Call the Action instance itself ActionForward forward = processActionPerform (request, response, action, form, mapping); / * protected ActionForward processActionPerform (HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) throws IOException, ServletException {

Try {Return (Action.execute (Mapping, Form, Request, Response);} catCH (Exception E) {Return (Request, Response, E, FORM, MAPPING);}

} * /

// Process the returned ActionForward instance processForwardConfig (request, response, forward); protected void processForwardConfig (HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) throws IOException, ServletException {if (forward == null) {return;} if (log.isDebugEnabled ()) {Log.debug ("" "" "String forwardPath = forward.getpath (); string uri = null; // paths not starting with / shop bepassed through a / (ie. they're absolute) IF (forwardpath.startswith ("/")) {uri = requestutils.ForwardURL (Request, Forward, Null); // Get Module Relative Uri} else {uri = forwardpath;} IF Forward.getRedirect ()) {// Only Prepend Context Path for relative uri if (uri.startsWith ( "/")) {uri = request.getContextPath () uri;} response.sendRedirect (response.encodeRedirectURL (uri));} else {doForward (uri, request, response); }

}

}

protected void doForward (String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {// Unwrap the multipart request, if there is one if (request instanceof MultipartRequestWrapper) {request = ((MultipartRequestWrapper) request) .getRequest ().; }

转载请注明原文地址:https://www.9cbs.com/read-50810.html

New Post(0)