struts中ActionServlet核心处理RequestProcessor.process()

本文详细介绍了Struts2框架处理HTTP请求的过程,包括国际化处理、内容编码设定、缓存控制、前置处理、ActionForm处理及验证、Action执行与转发配置等关键步骤。

public void process(HttpServletRequest request,
                    HttpServletResponse response)
    throws IOException, ServletException {

    // 处理 contentType 为 multipart/form-data 的 POST 请求,如果是则将请求包装,否则,返回原有

    //请求,一般来说,除非是要处理文件上传,否则不用关心
    request = processMultipart(request);

    //取得 URI 路径
    String path = processPath(request, response);
    if (path == null) {
        return;
    }
   
    if (log.isDebugEnabled()) {
        log.debug("Processing a '" + request.getMethod() +
                  "' for path '" + path + "'");
    }

    // 处理一些国际化的事务
    processLocale(request, response);

    // 决定请求的Content编码方式。指定响应结果内容类型和字符编码,默认是text/html
    processContent(request, response);

    //nochache如果是true在响应结果中加入特定的头参数
    processNoCache(request, response);

    // /前置处理,默认返回 true,子类可以重新定义它以決定要不要继续处理

    if (!processPreprocess(request, response)) {
        return;
    }
   
    this.processCachedMessages(request, response);

    //根据客户请求信息的path来决定是否返回ActionMapping实例。

    //如果不能找到path的映射则先看是否actionMapping中有unknown属性 有返回,没有这客户将会得到一个error响应
    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;
    }

    // 处理ActionForm,如果沒有就新增一个,之后一直使用它
   //首先先检查是否存在ActionMapping配置的ActionForm。如果存在,
   //则在有效区域查找是否存在该ActionForm实例,存在则复用,不存在则创建一个实例
   //然后将实例保存在配置文件中的有效域(request,session)内,
   //并用mapping.getAttribute()作key值


    ActionForm form = processActionForm(request, response, mapping);
    // 如果存在ActionMapping配置的ActionForm,则封装请求对象的数据
    //到ActionForm中,在封装之前,先调用ActionForm的reset()方法进行属性值的默认化


    processPopulate(request, response, form, mapping);
   
    // 如果ActionForm被配置好,并且action元素的属性Validate被设置为true,
    //则进一步调用validate()方法进行规则校验。如果validate()方法校验失败,
    //就会保存一个ActionErrors对象到请求域中,请求将自动重定向到action映射的
    //input属性所指向的页面中。如果校验通过或action映射中没有配置ActionForm,
    //则继续处理请求


    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;
    }
       
    // 判断 <action> 标签的 forwardinclude 标签是不是被设定
   // 这两个标签在设定一個路径,其与 type 属性是互斥的,当设定
   // 其中一个属性时,调用 RequestDispatcher 的 forward() 或
   // include() ,其作用与设定ForwardAction或IncludeAction相同
   // 直接传送而不再使用Action物件进行接下来的处理
    if (!processForward(request, response, mapping)) {
        return;
    }
   
    if (!processInclude(request, response, mapping)) {
        return;
    }

   //创建或获得action实例来处理此请求
    // 处理action,如果沒有就生成一个,之后一直使用它
    Action action = processActionCreate(request, response, mapping);
    if (action == null) {
        return;
    }

    // 调用Action的execute()方法,并反回ActionForward
    ActionForward forward =
        processActionPerform(request, response,
                             action, form, mapping);

    //处理返回来的ActionForward
    processForwardConfig(request, response, forward);

}

127.0.0.1:7001/dcms_index.view? 华夏银行 在线客服 户管理 bjq 审会会议通知信任务池 本会会议纪要企业资产证券化管理 Error 500--Internal Server Error 受信额度停用申请放款管理 贷后管理 javax. servlet.isp.IsnException. Exception creating bean of class com.ebworx. hxb. mcif. training.struts. controller. TrainingLscCustomerActionForm:(1) 同一务人管理 跨条线副资管理 at org. apache.struts.taglib.html. FormIag. doStartTag (FornTag.java:520) at org.apache.struts. taglib.html.FormIag.initFormBean (FormTag.java:563) at org. apache.strutsel.taglib.html.ELFormTag.doStartTag(ELFormTag.java:324) 档案管理 at jsp_servlet._dcms._base._menu_interface._jsp_tag2(_menu_interface. java:204) 回收与清侃 at weblogic.servlet. jsp.JspBase.service(JspBase.java:34) at jsp_servlet._dcms._base.__menu_interface._jspService(_menu_interface.java 130) 调整业务信息 at weblogic.servlet.internal. StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) 调整流星信息 at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) 系统参数维护 at weblogic.servlet.internal.TailFilter.doFilter (TailFilter.java:26) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) 报表查询 at weblogic.servlet.internal.FilterChainInpl.doFilter (FilterChainImpl.java:56) 信息与公告 at com.haian.hxb.itsm.filter.XssFilter.doFilter (XssFilter.java:30) at weblogic.servlet.internal.FilterChainImpl. doFilter (FilterChainImpl.java:56) 担保变更 at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:527) 调整用户电息 at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253) at common.web.struts.service.RequestProcessor.doForvard (RequestProcessor.java:1067) at common.web.struts. service.RequestProcessor.internalModuleRelativeForvard(RequestProcessor.java:1010) at common.web.struts. service.RequestProcessor.processForvard(RequestProcessor.java:580) at common.web.struts. service.RequestProcessor. process(RequestProcessor.java:257) at org.apache.struts.action.ActionServlet,process(ActionServlet.java:1482) at org.apache. struts.action.ActionServlet.doGet (ActionServlet.Java:507) iosyearulet rernceHetnSarx]et:7071 DevTools is now available in Chinesel Always match Chrome's language Switch DevTools to Chinese Dontsnow agan Elements Console Sources Network Performance Memory Application Security Lighthouse Recorder Performance insights A Preserve log□Disable cache No throttling Fiter 1nvert Hide data URLs☑Hide extension URLc All Fotch/XHR oos Css s Font img Meda Manifest Ws walm other o Blcked reauest 20000ms 40000
最新发布
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值