Struts 1.2.2 New Functional Experience (2)

xiaoxiao2021-03-06  64

Struts 1.2.2 experience new features (b) Date: 2004-09-07 Author: 2002PP

From 1.2.2, the functionality of the ISCANCELLED in Dispatch is started. Only the Cancelled method of Override Dispatchaction is required in the subclass of the DispatchAction, without having to implement it through the Override Execute method in 1.1. As for the principle of implementation See the Dispatchction source code in Struts1.1.2 below.

/ ** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an ActionForward instance describing where and how * control should be forwarded, or null if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception Exception if an exception occurs * / public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {// 1.2.2 Note that the following new code if (isCancelled (request )) {ActionForward Af = Cancelled (Mapping, Form, Req uest, response); if (af = null)! {return af;}} // Identify the request parameter containing the method name String parameter = mapping.getParameter (); if (parameter == null) {String message = messages. GetMessage ("Dispatch.Handler", mapping.getpath ());

Log.Error (Message);

Throw new servletexception (message);

// Get the method's name This could be overridden in subclasses String name = getMethodName (mapping, form, request, response, parameter);.. // Prevent recursive calls if ( "execute" .equals (name) || "perform" . Equals (name) {string message = messages.getMessage ("Dispatch.Recursive", mapping.getpath ());

Log.Error (Message); throw new servletexception (message);

/ ** * In DispatchAction subclasses Override this method requires! * Method which is dispatched to when the request is a cancel button submit. * Subclasses of DispatchAction should override this method if * they wish to provide default behavior different than returning null. * @since struts 1.2.0 * / protected map, actionmapping mapping, actionform form, httpservletRequest request, httpservletResponse response "throws Exception {

Return NULL;

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

New Post(0)