
/**//*遍历此方法的业务逻辑可知,*的优先级最高,如果是*,则不调用任何方法直接Forward,类似于ForwardAction*/?
private?static?final?String?NO_METHOD_CALL?=?"*";?
…….?
/**//*所有的FormBean都继承于BaseBean*/?
BaseBean?bean?=?(BaseBean)?form;?
??????ActionContext.initCurrentContext(request,?response);?
??????if?(bean?!=?null)?
{?
????????//?Explicit?Method?Mapping?
/**//*下面是检查struts.xml配置中是否有parameter属性*/?
????????Method?method?=?null;?
????????String?methodName?=?mapping.getParameter();?
????????if?(methodName?!=?null?&&?!NO_METHOD_CALL.equals(methodName))?
{?
??????????try?
{?
/**//*通过反射,根据得到的方法名称取得方法的句柄*/?
????????????method?=?bean.getClass().getMethod(methodName,?null);?
????????????synchronized?(bean)?
{?
/**//*下面是关键一句,调用basebean拥有的接口ActionInterceptor的实现DefaultActionInterceptor,来完成具体方法的调用*/?
??????????????forward?=?bean.getInterceptor().intercept(new?ActionInvoker(bean,?method));?
????????????}?
?????????……..?
/**//*无Parameter属性,检查path路径的最后一个/后的名称,即为调用的方法名*/?
????????//?Path?Based?Method?Mapping?
????????if?(method?==?null?&&?!NO_METHOD_CALL.equals(methodName))?
{?
??????????methodName?=?mapping.getPath();?
??????????if?(methodName.length()?>?1)?
{?
????????????int?slash?=?methodName.lastIndexOf("/")?+?1;?
????????????methodName?=?methodName.substring(slash);?
????????????if?(methodName.length()?>?0)?
{?
??????????????try?
{?
????????????????method?=?bean.getClass().getMethod(methodName,?null);?
????????????????synchronized?(bean)?
{?
??????????????????forward?=?bean.getInterceptor().intercept(new?ActionInvoker(bean,?method));?
????????????????}?
?????????????……..?
/**//*根据调用方法返回的String,得到页面的转移路径*/?
return?mapping.findForward(forward);?

/**//*通过反射,根据得到的方法名称取得方法的句柄*/?
????????????method?=?bean.getClass().getMethod(methodName,?null);?
????????????synchronized?(bean)?
{?
/**//*下面是关键一句,调用basebean拥有的接口ActionInterceptor的实现DefaultActionInterceptor,来完成具体方法的调用*/?
??????????????forward?=?bean.getInterceptor().intercept(new?ActionInvoker(bean,?method));?
????????????}?

public?String?invoke()?
{?
????try?
{?
??????return?(String)?method.invoke(bean,?null);?
????}?catch?(Exception?e)?
{?
??????throw?new?BeanActionException("Error?invoking?Action.??Cause:?"?+?e,?e);?
????}?
??}?
??? |
<action?path="/shop/viewOrder"?type="com.ibatis.struts.BeanAction"
????name="orderBean"?scope="session"
????validate="false">
????<forward?name="success"?path="/order/ViewOrder.jsp"/>
??</action>
<action?path="/shop/viewOrder"?type="com.ibatis.struts.BeanAction"
????name="orderBean"?parameter="viewOrder"?scope="session"
????validate="false">
????<forward?name="success"?path="/order/ViewOrder.jsp"/>
??</action>
?<action?path="/shop/viewOrder"?type="com.ibatis.struts.BeanAction"
????name="orderBean"?parameter="*"?scope="session"
????validate="false">
????<forward?name="success"?path="/order/ViewOrder.jsp"/>
??</action>
<action?path="/shop/viewOrder"?type="org.apache.struts.actions.ForwardAction" ????parameter="/order/ViewOrder.jsp?"?scope="session"?validate="false"> ?</action> ?![]() |