📄 multipledelegatingtilesrequestprocessor.java
字号:
if (uri == null) {
return false;
}
// Execute controller associated to definition, if any.
if (controller != null) {
try {
controller.execute(tileContext, request, response, getServletContext());
} catch (Exception e) {
throw new ServletException(e);
}
}
// If request comes from a previous Tile, do an include.
// This allows to insert an action in a Tile.
if (log.isDebugEnabled()) {
log.debug("uri=" + uri + " doInclude=" + doInclude);
}
if (doInclude) {
doInclude(uri, request, response);
} else {
doForward(uri, request, response); // original behavior
}
return true;
}
/**
* <p>Process a forward requested by this mapping (if any). Return
* <code>true</code> if standard processing should continue, or
* <code>false</code> if we have already handled this request.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param mapping The ActionMapping we are using
*/
protected boolean processForward(HttpServletRequest request, HttpServletResponse response,
ActionMapping mapping) throws IOException, ServletException {
// Are we going to processing this request?
String forward = mapping.getForward();
if (forward == null) {
return (true);
}
internalModuleRelativeForward(forward, request, response);
return (false);
}
/**
* <p>Process an include requested by this mapping (if any). Return
* <code>true</code> if standard processing should continue, or
* <code>false</code> if we have already handled this request.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param mapping The ActionMapping we are using
*/
protected boolean processInclude(HttpServletRequest request, HttpServletResponse response,
ActionMapping mapping) throws IOException, ServletException {
// Are we going to processing this request?
String include = mapping.getInclude();
if (include == null) {
return (true);
}
internalModuleRelativeInclude(include, request, response);
return (false);
}
/**
* <p>Do a module relative forward to specified URI using request dispatcher.
* URI is relative to the current module. The real URI is compute by prefixing
* the module name.</p>
* <p>This method is used internally and is not part of the public API. It is
* advised to not use it in subclasses. </p>
*
* @param uri Module-relative URI to forward to
* @param request Current page request
* @param response Current page response
*
* @since Struts 1.1
*/
protected void internalModuleRelativeForward(String uri, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
// Construct a request dispatcher for the specified path
uri = moduleConfig.getPrefix() + uri;
// Delegate the processing of this request
// :FIXME: - exception handling?
if (log.isDebugEnabled()) {
log.debug(" Delegating via forward to '" + uri + "'");
}
doForward(uri, request, response);
}
/**
* <p>Do a module relative include to specified URI using request dispatcher.
* URI is relative to the current module. The real URI is compute by prefixing
* the module name.</p>
* <p>This method is used internally and is not part of the public API. It is
* advised to not use it in subclasses.</p>
*
* @param uri Module-relative URI to include
* @param request Current page request
* @param response Current page response
*
* @since Struts 1.1
*/
protected void internalModuleRelativeInclude(String uri, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
// Construct a request dispatcher for the specified path
uri = moduleConfig.getPrefix() + uri;
// Delegate the processing of this request
// FIXME - exception handling?
if (log.isDebugEnabled()) {
log.debug(" Delegating via include to '" + uri + "'");
}
doInclude(uri, request, response);
}
/**
* <p>Do a forward to specified URI using a <code>RequestDispatcher</code>.
* This method is used by all internal method needing to do a forward.</p>
*
* @param uri Context-relative URI to forward to
* @param request Current page request
* @param response Current page response
* @since Struts 1.1
*/
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();
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null) {
URL resource = WebApplicationContextUtils.getWebApplicationContext(getServletContext())
.getResource(uri).getURL();
response.sendRedirect(resource.toString());
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage("requestDispatcher", uri));
return;
}
rd.forward(request, response);
}
/**
* <p>Do an include of specified URI using a <code>RequestDispatcher</code>.
* This method is used by all internal method needing to do an include.</p>
*
* @param uri Context-relative URI to include
* @param request Current page request
* @param response Current page response
* @since Struts 1.1
*/
protected void doInclude(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();
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage("requestDispatcher", uri));
return;
}
rd.include(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -