- 浏览: 307422 次
- 性别:
- 来自: 郴州
-
文章分类
- 全部博客 (70)
- hadoop (0)
- lucene (1)
- heritrix (1)
- webservice (0)
- css+div (0)
- java (29)
- javaweb (3)
- spring (2)
- hibernate (3)
- struts (5)
- struts2 (3)
- tomcat (1)
- map/reduce (0)
- ajax (0)
- android (3)
- oracle (3)
- 面试题 (1)
- 生活 (0)
- 开发工具 (1)
- 面试实习 (0)
- 设计模式 (3)
- 数据结构 (5)
- 论坛 (2)
- flex (3)
- PureMVC (1)
- java,jdk (1)
- sql server (1)
- 报表 (1)
- 算法 (4)
- 工作 (0)
最新评论
-
lp895876294:
第三种方式类似于工厂方法模式了
设计模式之单例模式(三种实现方式) -
xchsh12345:
如果用的是linux服务器呢
解决利用iText导出PDF报表中文乱码两种方式 -
memoryisking:
写的不错,关于Timer和TimeTask的内容网上资料挺多的 ...
Java定时调度 Timer类和TimerTask类 -
linfeng0169:
写的不错~!不过就是解释的不算好!
Calendar类add()与roll()方法的区别 -
u013606853:
好流弊的样子,LZ V5~
hibernate注解详解
Struts控制器组件主要包括:
ActionServlet组件:充当Struts框架的中央控制器。
RequestProcess组件:充当每个子应用模块的请求处理器。
Action组件:负责处理一项具体的业务。
对于多应用模块的Struts应用,每个子应用模块都有各自的RequestProcessor实例。在ActionServlet的process()方法中,一旦选择了正确的子应用模块,就会调用子应用模块的RequestProcessor实例的process()方法来处理请求。在ActionServlet调用这个方法时,会把当前的request和response对象传给它。
下面是RequestProcessor类的源代码:
ActionServlet组件:充当Struts框架的中央控制器。
RequestProcess组件:充当每个子应用模块的请求处理器。
Action组件:负责处理一项具体的业务。
对于多应用模块的Struts应用,每个子应用模块都有各自的RequestProcessor实例。在ActionServlet的process()方法中,一旦选择了正确的子应用模块,就会调用子应用模块的RequestProcessor实例的process()方法来处理请求。在ActionServlet调用这个方法时,会把当前的request和response对象传给它。
下面是RequestProcessor类的源代码:
package org.apache.struts.action; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.Globals; import org.apache.struts.config.ActionConfig; import org.apache.struts.config.ExceptionConfig; import org.apache.struts.config.ForwardConfig; import org.apache.struts.config.ModuleConfig; import org.apache.struts.upload.MultipartRequestWrapper; import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; public class RequestProcessor { // ----------------------------------------------------- Manifest Constants /** * <p>The request attribute under which the path information is stored for * processing during a <code>RequestDispatcher.include</code> call.</p> */ public static final String INCLUDE_PATH_INFO = "javax.servlet.include.path_info"; /** * <p>The request attribute under which the servlet path information is * stored for processing during a <code>RequestDispatcher.include</code> * call.</p> */ public static final String INCLUDE_SERVLET_PATH = "javax.servlet.include.servlet_path"; /** * <p>Commons Logging instance.</p> */ protected static Log log = LogFactory.getLog(RequestProcessor.class); // ----------------------------------------------------- Instance Variables /** * <p>The set of <code>Action</code> instances that have been created and * initialized, keyed by the fully qualified Java class name of the * <code>Action</code> class.</p> */ protected HashMap actions = new HashMap(); /** * <p>The <code>ModuleConfiguration</code> with which we are * associated.</p> */ protected ModuleConfig moduleConfig = null; /** * <p>The servlet with which we are associated.</p> */ protected ActionServlet servlet = null; // --------------------------------------------------------- Public Methods /** * <p>Clean up in preparation for a shutdown of this application.</p> */ public void destroy() { synchronized (this.actions) { Iterator actions = this.actions.values().iterator(); while (actions.hasNext()) { Action action = (Action) actions.next(); action.setServlet(null); } this.actions.clear(); } this.servlet = null; } /** * <p>Initialize this request processor instance.</p> * * @param servlet The ActionServlet we are associated with * @param moduleConfig The ModuleConfig we are associated with. * @throws ServletException If an error occor during initialization */ public void init(ActionServlet servlet, ModuleConfig moduleConfig) throws ServletException { synchronized (actions) { actions.clear(); } this.servlet = servlet; this.moduleConfig = moduleConfig; } /** * <p>Process an <code>HttpServletRequest</code> and create the * corresponding <code>HttpServletResponse</code> or dispatch to another * resource.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @throws IOException if an input/output error occurs * @throws ServletException if a processing exception occurs */ 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.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); // 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); // Validate any fields of the ActionForm bean, if applicable try { if (!processValidate(request, response, form, mapping)) { return; } } catch (InvalidCancelException e) { ActionForward forward = processException(request, response, e, form, mapping); processForwardConfig(request, response, forward); return; } catch (IOException e) { throw e; } catch (ServletException e) { throw e; } // 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 processForwardConfig(request, response, forward); } // ----------------------------------------------------- Processing Methods /** * <p>Return an <code>Action</code> instance that will be used to process * the current request, creating a new one if necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param mapping The mapping we are using * @return An <code>Action</code> instance that will be used to process * the current request. * @throws IOException if an input/output error occurs */ protected Action processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException { // Acquire the Action instance we will be using (if there is one) String className = mapping.getType(); if (log.isDebugEnabled()) { log.debug(" Looking for Action instance for class " + className); } // If there were a mapping property indicating whether // an Action were a singleton or not ([true]), // could we just instantiate and return a new instance here? Action instance; synchronized (actions) { // Return any existing Action instance of this class instance = (Action) actions.get(className); if (instance != null) { if (log.isTraceEnabled()) { log.trace(" Returning existing Action instance"); } return (instance); } // Create and return a new Action instance if (log.isTraceEnabled()) { log.trace(" Creating new Action instance"); } try { instance = (Action) RequestUtils.applicationInstance(className); // Maybe we should propagate this exception // instead of returning null. } catch (Exception e) { log.error(getInternal().getMessage("actionCreate", mapping.getPath()), e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getInternal().getMessage("actionCreate", mapping.getPath())); return (null); } actions.put(className, instance); if (instance.getServlet() == null) { instance.setServlet(this.servlet); } } return (instance); } /** * <p>Retrieve and return the <code>ActionForm</code> associated with this * mapping, creating and retaining one if necessary. If there is no * <code>ActionForm</code> associated with this mapping, return * <code>null</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param mapping The mapping we are using * @return The <code>ActionForm</code> associated with this mapping. */ 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); 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); } /** * <p>Forward or redirect to the specified destination, by the specified * mechanism. This method uses a <code>ForwardConfig</code> object * instead an <code>ActionForward</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param forward The ForwardConfig controlling where we go next * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ protected void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) throws IOException, ServletException { if (forward == null) { return; } if (log.isDebugEnabled()) { log.debug("processForwardConfig(" + forward + ")"); } String forwardPath = forward.getPath(); String uri; // If the forward can be unaliased into an action, then use the path of the action String actionIdPath = RequestUtils.actionIdURL(forward, request, servlet); if (actionIdPath != null) { forwardPath = actionIdPath; ForwardConfig actionIdForward = new ForwardConfig(forward); actionIdForward.setPath(actionIdPath); forward = actionIdForward; } // paths not starting with / should be passed through without any // processing (ie. they're absolute) if (forwardPath.startsWith("/")) { // get module relative uri uri = RequestUtils.forwardURL(request, forward, null); } 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); } } // :FIXME: if Action.execute throws Exception, and Action.process has been // removed, should the process* methods still throw IOException, // ServletException? /** * <P>Ask the specified <code>Action</code> instance to handle this * request. Return the <code>ActionForward</code> instance (if any) * returned by the called <code>Action</code> for further processing. * </P> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param action The Action instance to be used * @param form The ActionForm instance to pass to this Action * @param mapping The ActionMapping instance to pass to this Action * @return The <code>ActionForward</code> instance (if any) returned by * the called <code>Action</code>. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ 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 (processException(request, response, e, form, mapping)); } } /** * <p>Removes any <code>ActionMessages</code> object stored in the session * under <code>Globals.MESSAGE_KEY</code> and <code>Globals.ERROR_KEY</code> * if the messages' <code>isAccessed</code> method returns true. This * allows messages to be stored in the session, display one time, and be * released here.</p> * * @param request The servlet request we are processing. * @param response The servlet response we are creating. * @since Struts 1.2 */ protected void processCachedMessages(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (session == null) { return; } // Remove messages as needed ActionMessages messages = (ActionMessages) session.getAttribute(Globals.MESSAGE_KEY); if (messages != null) { if (messages.isAccessed()) { session.removeAttribute(Globals.MESSAGE_KEY); } } // Remove error messages as needed messages = (ActionMessages) session.getAttribute(Globals.ERROR_KEY); if (messages != null) { if (messages.isAccessed()) { session.removeAttribute(Globals.ERROR_KEY); } } } /** * <p>Set the default content type (with optional character encoding) for * all responses if requested. <strong>NOTE</strong> - This header will * be overridden automatically if a <code>RequestDispatcher.forward</code> * call is ultimately invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processContent(HttpServletRequest request, HttpServletResponse response) { String contentType = moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { response.setContentType(contentType); } } /** * <p>Ask our exception handler to handle the exception. Return the * <code>ActionForward</code> instance (if any) returned by the called * <code>ExceptionHandler</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are processing * @param exception The exception being handled * @param form The ActionForm we are processing * @param mapping The ActionMapping we are using * @return The <code>ActionForward</code> instance (if any) returned by * the called <code>ExceptionHandler</code>. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ protected ActionForward processException(HttpServletRequest request, HttpServletResponse response, Exception exception, ActionForm form, ActionMapping mapping) throws IOException, ServletException { // Is there a defined handler for this exception? ExceptionConfig config = mapping.findException(exception.getClass()); if (config == null) { log.warn(getInternal().getMessage("unhandledException", exception.getClass())); if (exception instanceof IOException) { throw (IOException) exception; } else if (exception instanceof ServletException) { throw (ServletException) exception; } else { throw new ServletException(exception); } } // Use the configured exception handling try { ExceptionHandler handler = (ExceptionHandler) RequestUtils.applicationInstance(config .getHandler()); return (handler.execute(exception, config, mapping, form, request, response)); } catch (Exception e) { throw new ServletException(e); } } /** * <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 * @return <code>true</code> to continue normal processing; * <code>false</code> if a response has been created. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ 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); } // If the forward can be unaliased into an action, then use the path of the action String actionIdPath = RequestUtils.actionIdURL(forward, this.moduleConfig, this.servlet); if (actionIdPath != null) { forward = actionIdPath; } 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 * @return <code>true</code> to continue normal processing; * <code>false</code> if a response has been created. * @throws IOException if an input/output error occurs * @throws ServletException if thrown by invoked methods */ 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); } // If the forward can be unaliased into an action, then use the path of the action String actionIdPath = RequestUtils.actionIdURL(include, this.moduleConfig, this.servlet); if (actionIdPath != null) { include = actionIdPath; } internalModuleRelativeInclude(include, request, response); return (false); } /** * <p>Automatically select a <code>Locale</code> for the current user, if * requested. <strong>NOTE</strong> - configuring Locale selection will * trigger the creation of a new <code>HttpSession</code> if * necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; } // Has a Locale already been selected? HttpSession session = request.getSession(); if (session.getAttribute(Globals.LOCALE_KEY) != null) { return; } // Use the Locale returned by the servlet container (if any) Locale locale = request.getLocale(); if (locale != null) { if (log.isDebugEnabled()) { log.debug(" Setting user locale '" + locale + "'"); } session.setAttribute(Globals.LOCALE_KEY, locale); } } /** * <p>Select the mapping used to process the selection path for this * request. If no mapping can be identified, create an error response and * return <code>null</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param path The portion of the request URI for selecting a mapping * @return The mapping used to process the selection path for this * request. * @throws IOException if an input/output error occurs */ protected ActionMapping processMapping(HttpServletRequest request, HttpServletResponse response, String path) throws IOException { // Is there a mapping for this path? ActionMapping mapping = (ActionMapping) moduleConfig.findActionConfig(path); // If a mapping is found, put it in the request and return it if (mapping != null) { request.setAttribute(Globals.MAPPING_KEY, mapping); return (mapping); } // Locate the mapping for unknown paths (if any) ActionConfig[] configs = moduleConfig.findActionConfigs(); for (int i = 0; i < configs.length; i++) { if (configs[i].getUnknown()) { mapping = (ActionMapping) configs[i]; request.setAttribute(Globals.MAPPING_KEY, mapping); return (mapping); } } // No mapping can be found to process this request String msg = getInternal().getMessage("processInvalid"); log.error(msg + " " + path); response.sendError(HttpServletResponse.SC_NOT_FOUND, msg); return null; } /** * <p>If this is a multipart request, wrap it with a special wrapper. * Otherwise, return the request unchanged.</p> * * @param request The HttpServletRequest we are processing * @return A wrapped request, if the request is multipart; otherwise the * original 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); } } /** * <p>Set the no-cache headers for all responses, if requested. * <strong>NOTE</strong> - This header will be overridden automatically if * a <code>RequestDispatcher.forward</code> call is ultimately * invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processNoCache(HttpServletRequest request, HttpServletResponse response) { if (moduleConfig.getControllerConfig().getNocache()) { response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); } } /** * <p>Identify and return the path component (from the request URI) that * we will use to select an <code>ActionMapping</code> with which to * dispatch. If no such path can be identified, create an error response * and return <code>null</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @return The path that will be used to select an action mapping. * @throws IOException if an input/output error occurs */ protected String processPath(HttpServletRequest request, HttpServletResponse response) throws IOException { String path; // Set per request the original path for postback forms if (request.getAttribute(Globals.ORIGINAL_URI_KEY) == null) { request.setAttribute(Globals.ORIGINAL_URI_KEY, request.getServletPath()); } // For prefix matching, match on the path info (if any) path = (String) request.getAttribute(INCLUDE_PATH_INFO); if (path == null) { path = request.getPathInfo(); } if ((path != null) && (path.length() > 0)) { return (path); } // For extension matching, strip the module prefix and extension path = (String) request.getAttribute(INCLUDE_SERVLET_PATH); if (path == null) { path = request.getServletPath(); } String prefix = moduleConfig.getPrefix(); if (!path.startsWith(prefix)) { String msg = getInternal().getMessage("processPath"); log.error(msg + " " + request.getRequestURI()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); return null; } path = path.substring(prefix.length()); int slash = path.lastIndexOf("/"); int period = path.lastIndexOf("."); if ((period >= 0) && (period > slash)) { path = path.substring(0, period); } return (path); } /** * <p>Populate the properties of the specified <code>ActionForm</code> * instance from the request parameters included with this request. In * addition, request attribute <code>Globals.CANCEL_KEY</code> will be set * if the request was submitted with a button created by * <code>CancelTag</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param form The ActionForm instance we are populating * @param mapping The ActionMapping we are using * @throws ServletException if thrown by RequestUtils.populate() */ protected void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws ServletException { if (form == null) { return; } // Populate the bean properties of this ActionForm instance if (log.isDebugEnabled()) { log.debug(" Populating bean properties from this request"); } form.setServlet(this.servlet); form.reset(mapping, request); if (mapping.getMultipartClass() != null) { request.setAttribute(Globals.MULTIPART_KEY, mapping.getMultipartClass()); } RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(), request); // Set the cancellation request attribute if appropriate if ((request.getParameter(Globals.CANCEL_PROPERTY) != null) || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null)) { request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE); } } /** * <p>General-purpose preprocessing hook that can be overridden as * required by subclasses. Return <code>true</code> if you want standard * processing to continue, or <code>false</code> if the response has * already been completed. The default implementation does nothing.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @return <code>true</code> to continue normal processing; * <code>false</code> if a response has been created. */ protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) { return (true); } /** * <p>If this action is protected by security roles, make sure that the * current user possesses at least one of them. Return <code>true</code> * to continue normal processing, or <code>false</code> if an appropriate * response has been created and processing should terminate.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param mapping The mapping we are using * @return <code>true</code> to continue normal processing; * <code>false</code> if a response has been created. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ protected boolean processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException, ServletException { // Is this action protected by role requirements? String[] roles = mapping.getRoleNames(); if ((roles == null) || (roles.length < 1)) { return (true); } // Check the current user against the list of required roles for (int i = 0; i < roles.length; i++) { if (request.isUserInRole(roles[i])) { if (log.isDebugEnabled()) { log.debug(" User '" + request.getRemoteUser() + "' has role '" + roles[i] + "', granting access"); } return (true); } } // The current user is not authorized for this action if (log.isDebugEnabled()) { log.debug(" User '" + request.getRemoteUser() + "' does not have any required role, denying access"); } response.sendError(HttpServletResponse.SC_FORBIDDEN, getInternal().getMessage("notAuthorized", mapping.getPath())); return (false); } /** * <p>If this request was not cancelled, and the request's {@link * ActionMapping} has not disabled validation, call the * <code>validate</code> method of the specified {@link ActionForm}, and * forward to the input path if there were any errors. Return * <code>true</code> if we should continue processing, or * <code>false</code> if we have already forwarded control back to the * input form.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param form The ActionForm instance we are populating * @param mapping The ActionMapping we are using * @return <code>true</code> to continue normal processing; * <code>false</code> if a response has been created. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs * @throws InvalidCancelException if a cancellation is attempted * without the proper action configuration. */ protected boolean processValidate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws IOException, ServletException, InvalidCancelException { if (form == null) { return (true); } // Has validation been turned off for this mapping? if (!mapping.getValidate()) { return (true); } // Was this request cancelled? If it has been, the mapping also // needs to state whether the cancellation is permissable; otherwise // the cancellation is considered to be a symptom of a programmer // error or a spoof. if (request.getAttribute(Globals.CANCEL_KEY) != null) { if (mapping.getCancellable()) { if (log.isDebugEnabled()) { log.debug(" Cancelled transaction, skipping validation"); } return (true); } else { request.removeAttribute(Globals.CANCEL_KEY); throw new InvalidCancelException(); } } // 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.isTraceEnabled()) { log.trace(" No errors detected, accepting input"); } return (true); } // Special handling for multipart request if (form.getMultipartRequestHandler() != null) { if (log.isTraceEnabled()) { 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.isTraceEnabled()) { log.trace(" Validation failed but no input form available"); } response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getInternal().getMessage("noInput", mapping.getPath())); return (false); } // Save our error messages and return to the input form if possible if (log.isDebugEnabled()) { log.debug(" Validation failed, returning to '" + input + "'"); } request.setAttribute(Globals.ERROR_KEY, errors); if (moduleConfig.getControllerConfig().getInputForward()) { ForwardConfig forward = mapping.findForward(input); processForwardConfig(request, response, forward); } else { internalModuleRelativeForward(input, 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 * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs * @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 * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs * @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 * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs * @since Struts 1.1 */ protected void doForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { 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 * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs * @since Struts 1.1 */ protected void doInclude(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getInternal().getMessage("requestDispatcher", uri)); return; } rd.include(request, response); } // -------------------------------------------------------- Support Methods /** * <p>Return the <code>MessageResources</code> instance containing our * internal message strings.</p> * * @return The <code>MessageResources</code> instance containing our * internal message strings. */ protected MessageResources getInternal() { return (servlet.getInternal()); } /** * <p>Return the <code>ServletContext</code> for the web application in * which we are running.</p> * * @return The <code>ServletContext</code> for the web application. */ protected ServletContext getServletContext() { return (servlet.getServletContext()); } }
发表评论
-
Struts与Struts2的区别
2011-07-08 13:01 1201经过两天的面试, ... -
Struts1.3.10深入源代码之核心类ActionForward类
2011-06-13 21:36 1984Action类的execute()方法返回一个Action ... -
Struts1.3.10深入源代码之核心类ActionServlet类
2011-06-13 14:42 1614org.apache.struts.action.Action ... -
Struts1.3.10深入源代码之核心类Action类
2011-06-12 22:03 2089Action类是用户请求和业务处理逻辑之间的桥梁。每个Acti ...
相关推荐
深入研究Struts 1.3.10源代码,可以帮助我们掌握Web应用开发的基本架构,理解MVC模式在实践中的应用,以及学习如何通过配置和编程控制请求流程。同时,通过分析源码,还可以学习到如何处理HTTP请求,验证用户输入,...
1、文件内容:ibus-table-chinese-erbi-1.4.6-3.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/ibus-table-chinese-erbi-1.4.6-3.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊
选择Java后台技术和MySQL数据库,在前台界面为提升用户体验,使用Jquery、Ajax、CSS等技术进行布局。 系统包括两类用户:学生、管理员。 学生用户只要实现了前台信息的查看,打开首页,查看网站介绍、自习室信息、在线留言、轮播图信息公告等,通过点击首页的菜单跳转到对应的功能页面菜单,包括网站首页、自习室信息、注册登录、个人中心、后台登录。 学生用户通过账户账号登录,登录后具有所有的操作权限,如果没有登录,不能在线预约。学生用户退出系统将注销个人的登录信息。 管理员通过后台的登录页面,选择管理员权限后进行登录,管理员的权限包括轮播公告管理、老师学生信息管理和信息审核管理,管理员管理后点击退出,注销登录信息。 管理员用户具有在线交流的管理,自习室信息管理、自习室预约管理。 在线交流是对前台用户留言内容进行管理,删除留言信息,查看留言信息。
面向基层就业个性化大学生服务平台(源码+数据库+论文+ppt)java开发springboot框架javaweb,可做计算机毕业设计或课程设计 【功能需求】 面向基层就业个性化大学生服务平台(源码+数据库+论文+ppt)java开发springboot框架javaweb,可做计算机毕业设计或课程设计 面向基层就业个性化大学生服务平台中的管理员角色主要负责了如下功能操作。 (1)职业分类管理功能需求:对职业进行划分分类管理等。 (2)用户管理功能需求:对用户信息进行维护管理等。 (3)职业信息管理功能需求:对职业信息进行发布等。 (4)问卷信息管理功能需求:可以发布学生的问卷调查操作。 (5)个性化测试管理功能需求:可以发布个性化测试试题。 (6)试题管理功能需求:对测试试题进行增删改查操作。 (7)社区交流管理功能需求:对用户的交流论坛信息进行维护管理。 面向基层就业个性化大学生服务平台中的用户角色主要负责了如下功能操作。 (1)注册登录功能需求:没有账号的用户,可以输入账号,密码,昵称,邮箱等信息进行注册操作,注册后可以输入账号和密码进行登录。 (2)职业信息功能需求:用户可以对职业信息进行查看。 (3)问卷信息功能需求:可以在线进行问卷调查答卷操作。 (4)社区交流功能需求:可以在线进行社区交流。 (5)个性化测试功能需求:可以在线进行个性化测试。 (6)公告资讯功能需求:可以查看浏览系统发布的公告资讯信息。 【环境需要】 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.数据库:MySql 5.7/8.0等版本均可; 【购买须知】 本源码项目经过严格的调试,项目已确保无误,可直接用于课程实训或毕业设计提交。里面都有配套的运行环境软件,讲解视频,部署视频教程,一应俱全,可以自己按照教程导入运行。附有论文参考,使学习者能够快速掌握系统设计和实现的核心技术。
三菱Fx3u程序:自动检测包装机电机控制模板,PLC脉冲与伺服定位,手自动切换功能,三菱Fx3u程序:自动检测包装机电机控制模板——涵盖伺服定位与手自动切换功能,三菱Fx3u程序,自动检测包装机。 该程序六个电机,plc本体脉冲控制3个轴,3个1pg控制。 程序内包括伺服定位,手自动切,功能快的使用,可作为模板程序,很适合新手。 ,三菱Fx3u程序; 自动检测包装机; 六个电机; PLC脉冲控制; 伺服定位; 手自动切换; 功能快捷键; 模板程序。,三菱Fx3u PLC控制下的自动包装机程序:六电机伺服定位与手自动切换模板程序
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
计及信息间隙决策与多能转换的综合能源系统优化调度模型:实现碳经济最大化与源荷不确定性考量,基于信息间隙决策与多能转换的综合能源系统优化调度模型:源荷不确定性下的高效碳经济调度策略,计及信息间隙决策及多能转的综合能源系统优化调度 本代码构建了含风电、光伏、光热发电系统、燃气轮机、燃气锅炉、电锅炉、储气、储电、储碳、碳捕集装置的综合能源系统优化调度模型,并考虑P2G装置与碳捕集装置联合运行,从而实现碳经济的最大化,最重要的是本文引入了信息间隙决策理论考虑了源荷的不确定性(本代码的重点)与店铺的47代码形成鲜明的对比,注意擦亮眼睛,认准原创,该代码非常适合修改创新,,提供相关的模型资料 ,计及信息间隙决策; 综合能源系统; 优化调度; 多能转换; 碳经济最大化; 风电; 光伏; 燃气轮机; 储气; 储电; 储碳; 碳捕集装置; P2G装置联合运行; 模型资料,综合能源系统优化调度模型:基于信息间隙决策和多能转换的原创方案
IPG QCW激光模块电源驱动电路设计与实现:包含安全回路、紧急放电回路及光纤互锁功能的多版本原理图解析,IPG QCW激光模块电源驱动电路设计与实现:含安全回路、紧急放电及光纤互锁等多重保护功能的原理图解析,IPG QCW激光模块电源驱动电路, 包含安全回路,紧急放电回路,光纤互锁回路等, 元件参数请根据实际设计适当调整,此电路仅供参考,不提供pcb文件 原理图提供PDF和KICAD两个版本。 ,IPG激光模块; QCW激光电源驱动; 安全回路; 紧急放电回路; 光纤互锁回路; 原理图PDF和KICAD版本。,IPG激光模块电源驱动电路图解:含安全与紧急放电回路
基于LSSVM的短期电力负荷预测模型及其性能评估:结果揭露精确度与误差分析,LSSVM在短期电力负荷预测中的结果分析:基于均方根误差、平均绝对误差及平均相对百分误差的评估。,LSSVM最小二乘支持向量机做短期电力负荷预测。 结果分析 均方根误差(RMSE):0.79172 平均绝对误差(MAE):0.4871 平均相对百分误差(MAPE):13.079% ,LSSVM(最小二乘支持向量机);短期电力负荷预测;均方根误差(RMSE);平均绝对误差(MAE);平均相对百分误差(MAPE),LSSVM在电力负荷短期预测中的应用及性能分析
1、文件内容:libmtp-examples-1.1.14-1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/libmtp-examples-1.1.14-1.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊
资源内项目源码是均来自个人的课程设计、毕业设计或者具体项目,代码都测试ok,都是运行成功后才上传资源,答辩评审绝对信服的,拿来就能用。放心下载使用!源码、说明、论文、数据集一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 4、如有侵权请私信博主,感谢支持
2023-04-06-项目笔记-第四百一十六阶段-课前小分享_小分享1.坚持提交gitee 小分享2.作业中提交代码 小分享3.写代码注意代码风格 4.3.1变量的使用 4.4变量的作用域与生命周期 4.4.1局部变量的作用域 4.4.2全局变量的作用域 4.4.2.1全局变量的作用域_1 4.4.2.414局变量的作用域_414- 2025-02-21
MINIST数据集和春风机器学习框架
1、文件内容:ibus-table-chinese-wu-1.4.6-3.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/ibus-table-chinese-wu-1.4.6-3.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊
宿舍管理系统(源码+数据库+论文+ppt)java开发springboot框架javaweb,可做计算机毕业设计或课程设计 【功能需求】 系统拥有管理员和学生两个角色,主要具备系统首页、个人中心、学生管理、宿舍信息管理、宿舍分配管理、水电费管理、进入宿舍管理、出入宿舍管理、维修信息管理、卫生信息管理、考勤信息管理、留言板、交流论坛、系统管理等功能模块。 【环境需要】 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.数据库:MySql 5.7/8.0等版本均可; 【购买须知】 本源码项目经过严格的调试,项目已确保无误,可直接用于课程实训或毕业设计提交。里面都有配套的运行环境软件,讲解视频,部署视频教程,一应俱全,可以自己按照教程导入运行。附有论文参考,使学习者能够快速掌握系统设计和实现的核心技术。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
人凤飞飞凤飞飞是粉色丰富
2024蓝桥杯嵌入式学习资料
image_download_1740129191509.jpg
基于Multisim仿真的带优先病房呼叫系统设计(仿真图) 设计一个病房呼叫系统。 功能 (1)当有病人紧急呼叫时,产生声,光提示,并显示病人的编号; (2)根据病人的病情设计优先级别,当有多人呼叫时,病情严重者优先; (3)医护人员处理完当前最高级别的呼叫后,系统按优先级别显示其他呼叫病人的病号。