日期:2014-05-18  浏览次数:20679 次

dispatchAciton中某函数调用另一个函数,哪个forward生效?
下面有两个函数,第一个函数调用第二个函数,两个函数都有return,类型均为actionforward,经我试验,第一个函数中的return所指向的转向生效了。第二个函数中的actionForward所对应的jsp页面,没有生效,这是为什么呢?


public   final   ActionForward   toMaOption(
ActionMapping   mapping,
ActionForm   form,
HttpServletRequest   request,
HttpServletResponse   response)
          throws   Exception   {
orderAllQuery(
  mapping,
  form,
  request,
  response);
  return   mapping.findForward( "toMaOption ");
}

public   final   ActionForward   orderAllQuery(
ActionMapping   mapping,
ActionForm   form,
HttpServletRequest   request,
HttpServletResponse   response)
          throws   Exception   {

  return   mapping.findForward( "toQueryAll ");
}

------解决方案--------------------
up
------解决方案--------------------
public final ActionForward toMaOption(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

if(...)
{

return orderAllQuery(
mapping,
form,
request,
response);
else
{
return mapping.findForward( "toMaOption ");
}
}

------解决方案--------------------
在执行action的过程中,最后就是要返回指定的(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)页面.那么既然你第一个导航代码中先调用了第二个导航方法,return到了toMaOption页面,下面的代码自然不运行,那结果两个导航去的都是去的一个页面啦.