struts2的 result

struts2的result的type有很多,但是一些都不大常用!

dispatcher,redirect,chain,redirectAction!

dispatcher是默认的,运用服务器跳转(jsp:forward)到结果页面;不能跳转到一个action里;

redirect:跳转到视图,不能跳转到一个action里;

chain:forward到一个action!

redirectAction:客户端跳转!

struts.xml:

<struts>
	<constant name="struts.devMode" value="true" />
	<package name="result" extends="struts-default" namespace="/result">
		<action name="d1" class="cn.keith.resultType.ResultType">
			<result type="dispatcher">/d1.jsp</result>
		</action>
		<action name="d2" class="cn.keith.resultType.ResultType">
			<result type="redirect">/d2.jsp</result>
		</action>
		<action name="d3" class="cn.keith.resultType.ResultType">
			<result type="chain">d1</result>
		</action>
		<action name="d4" class="cn.keith.resultType.ResultType">
			<result type="redirectAction">d2</result>
		</action>
	</package>
</struts>

 jsp:

<a href="result/d1">测试dispatcher_d1</a>
	<a href="result/d2">测试redirect_d1</a>
	<a href="result/d3">测试chain_d1</a>
	<a href="result/d4">测试redirectAction_d1</a>

 可以测试下结果!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值