JSPCN主页 | JSP空间 | 网站制作 | JSP下载 | JSP论坛 | JSP教程 | 关于JSPCN | 联系我们
JSP虚拟主机,jsp空间,java空间,java虚拟空间,详细请点击进入
做最专业的JSP中文网站 当前位置首页--JSP技术--STRUTS  
文章搜索:
关键字 标题
  
JSP中文网内容管理系统(JCMS)
JSP虚拟主机
网络笔记本
网摘,图片,笔记收藏
虚拟服务器

JSPCN文章目录分类
JSP配置[219]JSP基础[136]
中文问题[69]上传问题[27]
JAVABEAN[46]数据库[212]
文件操作[126]图片声音[17]
JSP其他[57]时间相关[16]
JAVAMAIL[72]STRUTS[144]
开发工具[28]教程系列[157]
JSP实例[89]
JAVA基础[421]APPLET[78]
JAVA网络[179]Applica[115]
Servlet[98]XML[163]
J2ME[257]J2EE[374]
考试相关[63]JAVA线程[90]
EJB[261]Swing[26]
Java API[141]声音图片[28]
异常处理[33]JAVA实例[290]
JAVA类[139]SUN[89]
Hibernate[6]JMX[8]
Spring[34]
本版推荐文章 
本版热点文章 
相关文章链接 
 
Struts处理用户表单请求的核心源代码:
作者:     文章来源:
访问次数:281次     加入时间:2007年04月08日
Struts处理用户表单请求的核心源代码
Struts处理用户表单请求的核心源代码:





====================== ActionServlet ================================


/**



     * Process an HTTP "GET" request.



     *



     * @param request The servlet request we are processing



     * @param response The servlet response we are creating



     *



     * @exception IOException if an input/output error occurs



     * @exception ServletException if a servlet exception occurs



     */



    public void doGet(HttpServletRequest request,



              HttpServletResponse response)



        throws IOException, ServletException {







        process(request, response);







    }











    /**



     * Process an HTTP "POST" request.



     *



     * @param request The servlet request we are processing



     * @param response The servlet response we are creating



     *



     * @exception IOException if an input/output error occurs



     * @exception ServletException if a servlet exception occurs



     */



    public void doPost(HttpServletRequest request,



               HttpServletResponse response)



        throws IOException, ServletException {







        process(request, response);







    }

















    /**



     * Perform the standard request processing for this request, and create



     * the corresponding response.



     *



     * @param request The servlet request we are processing



     * @param response The servlet response we are creating



     *



     * @exception IOException if an input/output error occurs



     * @exception ServletException if a servlet exception is thrown



     */



    protected void process(HttpServletRequest request,



                           HttpServletResponse response)



        throws IOException, ServletException {







        RequestUtils.selectModule(request, getServletContext());



        getRequestProcessor(getModuleConfig(request)).process



            (request, response);







    }















__________________________________________________________________________


/**



     * Look up and return the {@link RequestProcessor} responsible for the



     * specified module, creating a new one if necessary.



     *



     * @param config The module configuration for which to



     *  acquire and return a RequestProcessor.



     *



     * @exception ServletException if we cannot instantiate a RequestProcessor



     *  instance



     * @since Struts 1.1



     */



    protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config)



        throws ServletException {    



            



        String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();



        RequestProcessor processor = (RequestProcessor)



            getServletContext().getAttribute(key);



            



        if (processor == null) {



            try {



                processor =



                    (RequestProcessor) RequestUtils.applicationInstance(



                        config.getControllerConfig().getProcessorClass());



                        



            } catch (Exception e) {



                throw new UnavailableException(



                    "Cannot initialize RequestProcessor of class "



                        + config.getControllerConfig().getProcessorClass()



                        + ": "



                        + e);



            }







            processor.init(this, config);



            getServletContext().setAttribute(key, processor);







        }



        return (processor);







    }



















======================= RequestProcessor ===========================


-------------------------------- RequestProcessor ------------------------------------------------------


/**



     * <p>Process an <code>HttpServletRequest</code> and create the



     * corresponding <code>HttpServletResponse</code>.</p>



     *



     * @param request The servlet request we are processing



     * @param response The servlet response we are creating



     *



     * @exception IOException if an input/output error occurs



     * @exception 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;



        }







        // 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



        processForwardConfig(request, response, forward);







    }











------------------------------------- RequestProcessor. --------------------------------------------------


/**



     * 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.



     *



     * @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



     *



     * @exception IOException if an input/output error occurs



     * @exception 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));



        }







    }
Copyright © 2002-2005 JSPCN.net. All rights reserved.
JSP中文网    备案序号:蜀ICP备05001583号
成都恒海科技发展有限公司    成都市一环路南二段6号新瑞楼三楼8号