ActionMapping总结

unknown和forward属性,input属性

首先明白ActionMapping一个实例对应了struts-config.xml文件中的一个<action>标签

forward属性:forward属性,如果配置了这个属性,那么你可以不用写action,在配置文件中配置一个空的action就可以了,那么他也可以通过这个来进行转向.
processForward这个方法:如果正常编写Action的话是不会进到这个方法里面的,这个方法就是用来处理action中forward属性的.

<action path="/login" forward="/login.jsp" ></action>


unknown属性:要.do请求才能用的,配置如下

<action path="/xxx" unknown="true" forward="/error.jsp"></action>

struts对他的处理过程:

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;
    }

input属性:与异常有关

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yjsuge

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值