Struts快速学习指南4(内部培训教材)-大部分素材来自于《Programming Jakarta Struts》一书

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

RequestProcessor类

前面提到过,当ActionServlet接收到客户请求后,会进行一连串的初始化操作,然后,就会将客户请求转交给合适的处理器进行处理,这个合适的处理器就是org.apache.struts.action.RequestProcessor或其子类的一个实例(根据Struts配置文件中的配置)。提供了默认实现,如果需要自定义这些行为,可以重载这个类定义自己的处理行为,当你想要自定义操作时,Struts推荐你重载这个类而不是ActionServlet。

下面的代码片断提供了RequestProcessor的默认行为实现代码:

public void process(HttpServletRequest request, HttpServletResponse response)

throws IOException, ServletException {

// Wrap multipart requests with a special wrapper

request = processMultipart(request);

// Identify the path component we will use to select a mapping

String path = processPath(request, response);

if (path == null) {

return;

}

if (log.isInfoEnabled( )) {

log.info("Processing a '" + request.getMethod( ) +

"' for path '" + path + "'");

}

// Select a Locale for the current user if requested

processLocale(request, response);

// Set the content type and no-caching headers if requested

processContent(request, response);

processNoCache(request, response);

// General-purpose preprocessing hook

if (!processPreprocess(request, response)) {

return;

}

// Identify the mapping for this request

ActionMapping mapping = processMapping(request, response, path);

if (mapping == null) {

return;

}

// Check for any role required to perform this action

if (!processRoles(request, response, mapping)) {

return;

}

// Process any ActionForm bean related to this request

ActionForm form = processActionForm(request, response, mapping);

processPopulate(request, response, form, mapping);

if (!processValidate(request, response, form, mapping)) {

return;

}

// Process a forward or include specified by this mapping

if (!processForward(request, response, mapping)) {

return;

}

if (!processInclude(request, response, mapping)) {

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);

// Process the returned ActionForward instance

processActionForward(request, response, forward);

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航