STRUTS2的源码分析

今天,好不容易把struts2的一个源码片段弄清楚了点,现在说说,让别人的类似疑惑暂定。

ok,我在2.2.1的版本看到

 

 

           // if the ActionMapping says to go straight to a result, do it!
            if (mapping.getResult() != null) {
                Result result = mapping.getResult();
                result.execute(proxy.getInvocation());
            } else {
                proxy.execute();
           
            }

 

在大部分想都是走ELSE路线,但是mapping.getResult() != null 是什么时候才能出现呢?在网上GOOGLE

 

" if the ActionMapping says to go straight to a result, do it!" 最后通常是找不到问题的原因的。

 

今天我发现问题的答案在 DefaultActionMapper 这个类的注释里面。

 

也就是当BUTTON的请求是

    <s:submit name="redirect:http://www.google.com.hk" value="Cancel"/>
   
    <s:submit name="redirectAction:list" value="Cancel122"/>

这样以

 

    protected static final String REDIRECT_PREFIX = "redirect:";

    protected static final String REDIRECT_ACTION_PREFIX = "redirectAction:";

 

redirect: 或者redirectAction:开头的button是走mapping.getResult() != null 路线的。

 

 如果有其他情况,请看客们说说,谢谢!

 


 

你可能感兴趣的:(Google,Go)