12. Struts2_result
来源:互联网 发布:思科网络架构师 编辑:程序博客网 时间:2024/06/06 07:40
每个 action 方法都将返回一个 String 类型的值, Struts 将根据这个值来决定响应什么结果.
每个 action 声明都必须包含有数量足够多的 result 元素, 每个 result 元素分别对应着 action 方法的一个返回值.
result 元素可以有下面两个属性
name: 结果的名字, 必须与 Action 方法的返回值相匹配, 默认值为 success
type: 响应结果的类型. 默认值为 dispatcher
/WEB-INF/views/success.jsp
dispatcher 结果类型是最常用的结果类型, 也是 struts 框架默认的结果类型
该结果类型有一个 location 参数, 它是一个默认参数
dispatcher 结果类型将把控制权转发给应用程序里的指定资源.
dispatcher 结果类型不能把控制权转发给一个外部资源. 若需要把控制权重定向到一个外部资源, 应该使用 redirect 结果类型
结果类型: redirect
redirect 结果类型将把响应重定向到另一个资源, 而不是转发给该资源.
redirect 结果类型接受下面这些参数:
location: 用来给出重定向的目的地.它是默认属性
parse: 用来表明是否把 location 参数的值视为一个 OGNL 表达式来解释. 默认值为 true
redirect 结果类型可以把响应重定向到一个外部资源
<!-- 重定向的时候要注意,不能通过重定向去访问web-info目录下的页面。能重定向到另外一个请求 请求要注意:是到对应的package下的:namespace+action下的name+默认的后缀名 <constant name="struts.action.extension" value="action,do"></constant> 即:package:namespace+action:name+struts.action.extension:value= /hgh/testaction.do <result name="redirectTest" type="redirect">/hgh/testaction.do</result> -->
结果类型: redirectAction
redirectAction 结果类型把响应重定向到另一个 Action
redirectAction 结果类型接受下面这些参数:
actionName: 指定 “目的地” action 的名字. 它是默认属性
namespace: 用来指定 “目的地” action 的命名空间. 如果没有配置该参数, Struts 会把当前 Action 所在的命名空间作为 “目的地” 的命名空间
<!-- 重定向到一个 Action --> <result name="redirectActionTest" type="redirectAction"> <param name="actionName">testaction</param> <param name="namespace">/hgh</param> </result>
- 12. Struts2_result
- Struts2_result
- Struts2_Result
- struts2_result-type
- struts2_result-type
- 6.Struts2_result
- (11)Struts2_result概述
- 11.Struts2_result概述
- 12. 马太效应
- 12.ABC
- 12. 文件
- 12.material
- 12.XML
- 12.效率
- 12.UIImage
- 12. 结构
- 12.autorelease
- 12.ui
- Android 学习路线图
- SqlServer2012建数据挖掘模型
- (自学收获)纯css网页小部件--tab切换
- N的阶乘的长度V2 【斯特林公式】
- java: Merge-two-sorted-lists
- 12. Struts2_result
- leetcode_304. Range Sum Query 2D
- jdk1.8 日期新API LocalDateTime,LocalDate,LocalTime 在Hibernate中无法反序列化解决方法
- 修复:XAMPP与VMware端口443占用问题“Port 443 in use by ...”
- 解决Windows安装解压版MySQL出现服务正在启动-服务无法启动的问题
- my knowledge
- 用uid分库,uname上的查询怎么办?
- 第4章 基本的Git概念
- 实现读写分离的Web工程