结果类型(result_type)

结果类型(result_type):默认为dispatcher,运用服务器跳转,跳转到结果页面, redirect 跳转到视图(JSP) 、chain forward 到action 、redirctAction 客户端跳转,跳转到Action
//index.jsp
result 类型:
<br />
<ol>
<li> <!-- 地址框显示action -->
<a href="r/r1">dispatcher</a> 运用服务器跳转,跳转到结果页面(体现在struts.xml配置中)
</li>
<li> <!-- 地址框显示JSP -->
<a href="r/r2">redirect</a> 跳转到视图(JSP)
</li>
<li> <!-- 地址框显示action -->
<a href="r/r3">chain</a> forward 到action
</li>
<li> <!-- 地址框显示JSP -->
<a href="r/r4">redirctAction</a> 客户端跳转,跳转到Action
</li>
<li>
freemarker
</li>
<li>
httpheader 发http头信息
</li>
<li>
stream 下载
</li>
<li>
velocity
</li>
<li>
xslt 与xml相关的语言
</li>
<li>
plaintext 显示页面源码,用于教学网站
</li>
<li>
tiles 将页面分块
</li>
</ol>
<br>
//struts.xml
<constant name="struts.devMode" value="true" />
<package name="resultTypes" namespace="/r" extends="struts-default">
<action name="r1"><!-- 地址框显示action -->
<result type="dispatcher">/r1.jsp</result> <!-- dispatcher只能跳转到页面,不能是action -->
</action>

<action name="r2"> <!-- 地址框显示JSP -->
<result type="redirect">/r2.jsp</result> <!-- 表示跳转到r2.jsp -->
</action>

<action name="r3"><!-- 地址框显示本action -->
<result type="chain">r1</result> <!-- 跳转到r1 action -->
</action>

<action name="r4">
<result type="redirectAction">r2</result> <!-- 地址框显示目的JSP -->
</action>
</package>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值