struts中的跳转问题

c_fans20 2007-03-08 02:39:12
如何实现从一个Action中跳转到另一个Action
...全文
283 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
gemini0526 2007-03-15
  • 打赏
  • 举报
回复
Action1里:return mapping.findforward("gotoanother");
struts-config.xml
<global-forwards >
<forward name="gotoanother" path="another.do"/>
</global-forwards>
ziyouzai 2007-03-15
  • 打赏
  • 举报
回复
return new ActionFoward("next.do");
SINCE1978 2007-03-12
  • 打赏
  • 举报
回复
而且发出forward转发的action和接收forward的action使用同一个form,这点要明白。
SINCE1978 2007-03-12
  • 打赏
  • 举报
回复
直接配置<forward...的path属性,指向一个ACTION即可。
ACTION和JSP在structs看来是同质的,都是一种资源。
aChinese 2007-03-09
  • 打赏
  • 举报
回复
往配置里一下, 直接forware过去不就得了
老鱼趣多多 2007-03-08
  • 打赏
  • 举报
回复
注意看此行,path="/userShow.do"
老鱼趣多多 2007-03-08
  • 打赏
  • 举报
回复
你想跳转到另一个action ,同样容易,比如把tache=2映射到跳转到userShowAction,
只要这样修改。
//配置struts-confg.xml
<action-mappings>
<action
attribute="loginForm"
name="loginForm"
path="login"
scope="request"
type="com.test.loginAction">
<forward
name="success1"
path="/login/success1.jsp"
redirect="true"/>
<forward
name="success2"
path="/userShow.do"
redirect="true"/>
</action>
</action-mappings>
老鱼趣多多 2007-03-08
  • 打赏
  • 举报
回复
//前面代码略
execute(,){

String strMapJump = null;
tacheNo = Integer.parseInt(request.getParameter("tacheNo"));
switch(tacheNo){

case 1:
strJumpMap = "success1";
break;

case 2:
strJumpMap = "success2";
break;
}

return mapping.findforward(strJumpMap);
}

//配置struts-confg.xml
<action-mappings>
<action
attribute="loginForm"
name="loginForm"
path="login"
scope="request"
type="com.test.loginAction">
<forward
name="success1"
path="/login/success1.jsp"
redirect="true"/>
<forward
name="success2"
path="/login/success2.jsp"
redirect="true"/>
</action>
</action-mappings>

根据传递的tacheNo值的不同,跳转到不同的页面。
朋友,可以看明白么?
andrew830314 2007-03-08
  • 打赏
  • 举报
回复
然后再重定向之后return null就OK了!
andrew830314 2007-03-08
  • 打赏
  • 举报
回复
倒!咋得都可以啊!不就和一个Servlet转到另一个Servlet一样吗?
你可以使用return new ActionForward(""),也可以response.sendRedirect("")啊!嘿嘿!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧