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

Struts中,ActionMapping怎么跳转到另一个Action方法?
比如说发布一个新帖子,点击提交后,页面跳转到论坛首页,  
  发布贴子是一个方法,跳转到论坛首页又是一个方法,怎么能使用ActionMapping 从发布帖子的方法跳转到初始化论坛首页的方法.
  就是说不是跳转到一个页面,而是跳转到另一个Action
   
  谢谢各位赐教!

------解决方案--------------------
把mapping返回的页面中,用JS实现自动加载首页的Action,这样经过两次跳转就到了论坛首页了。
------解决方案--------------------
ActionForward forward=new ActionForward("/*.do");
return forward;
------解决方案--------------------
struts配置文件里
<forward name="success" path="/dispAll.do" />这样写不就成了,path不一定非写JSP,可以写.do的
------解决方案--------------------
action中的跳转方法有很多中。
你可以用在action-mapping配置文件中配置,也可以用ActionRedirect。
actionRedirect的使用请查struts文档
------解决方案--------------------
return new ActionForward("/*.do");
------解决方案--------------------
直接在forward标签里写义一个应该可以吧。 那里不是只能写jsp页面的。。
------解决方案--------------------
<action attribute="queryCientContentForm"
input="/jsp/ClientContent/conditionselect.jsp"
name="queryCientContentForm" path="/queryCientContent"
scope="request"
type="com.crm.struts.action.clientcontent.QueryCientContentAction">
<forward name="clientlist2" path="/clientfen.do" />
</action>
写在forward里
------解决方案--------------------
其中另一个Struts Action 还应该有一个这样缺省方法!因为Action不知道你将要做什么!
protected ActionForward unspecified(
ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward("要跳转的面页");
}
------解决方案--------------------
给你举个例子<action path="/nsbo/menuTree"
type="com.newSpace.jp.action.MenuTreeAction">
<forward name="homepage" path="/tiles/mainTiles.jsp" />
<forward name="menuContent" path="/nsbo/preupdateMenu.do" />
<forward name="updataMenu"
path="/tiles/premenucontentTiles.jsp" />
<forward name="deleteMenu" path="/nsbo/showMenuList.do" />
</action>


<action path="/nsbo/showMenuList"
type="com.newSpace.jp.action.ShowMenuListAction" scope="request">
<forward name="menuList"
path="/tiles/menuresultlistTiles.jsp" />
</action>
最后path="/nsbo/showMenuList.do"才是关键
------解决方案--------------------
把xml文件的跳转的页面 改成action 
就是改成进入主页的action,而不是主页的JSP页面。