strutsr源码解读

2008-02-23 10:07:27来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

html:form

org.apache.Struts.action.ActionServlet;

ActionServlet extends HttpServlet

doGet
doPost

process(request, response);
{
processor = getRequestProcessor(config);
processor.process(request, response);
}

RequestProcessor 没有继承任何的类,只是一个repquest的处理器,逻辑封装
方法
public void process(HttpServletRequest request,
HttpServletResponse response)
{
//封装request
request = processMultipart(request);
/*
详细:
protected HttpServletRequest processMultipart(HttpServletRequest request) {

if (!"POST".equalsIgnoreCase(request.getMethod())) {
return (request);
}

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 可以忽略
if (log.isDebugEnabled()) {
log.debug("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;
}

this.processCachedMessages(request, response);
//end 忽略


// Identify the mapping for this request
ActionMapping mapping = processMapping(request, response, path);
if (mapping == null) {
return;
}
/*详细
根据path找到mapping
*/

// Check for any role required to perform this action
if (!processRoles(request, response, mapping)) {
return;
}

//action form 的处理
// Process any ActionForm bean related to this request
ActionForm form = processActionForm(request, response, mapping);
/*
用mapping找actionform
protected ActionForm processActionForm(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping) {

// Create (if necessary) a form bean to use
ActionForm instance = RequestUtils.createActionForm
(request, mapping, moduleConfig, servlet);
/*详细
ActionForm instance = lookupActionForm(request, attribute, mapping.getScope());
if (instance != null && canReuseActionForm(instance, config)) {
return (instance);
否则
return createActionForm(config, servlet);
*/
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.setAttribute(mapping.getAttribute(), instance);
} else {
HttpSession session = request.getSession();
session.setAttribute(mapping.getAttribute(), instance);
}
return (instance);

}

*/
processPopulate(request, response, form, mapping);
/*
RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(),
request);

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

if (form == null) {
return (true);

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:[Eclipse CON 2005摘录]Eclipse创世纪

下一篇:JAVA:附加码生成器(图片)