struts2 result随笔
一、result:chain(从一个Action转发到另一个Action)
chain结果类型有4个属性,分别是:
actionName (default) - the name of the action that will be chained to
namespace - used to determine which namespace the Action is in that we're chaining. If namespace is null, this defaults to the current namespace
method - used to specify another method on target action to be invoked. If null, this defaults to execute method
skipActions - (optional) the list of comma separated action names for the actions that could be chained to
eg:
public String hotGoods() {
try {
QueryRule queryRule=QueryRule.getInstance();
queryRule.addEqual("isNew", "0");
List<ProductInfo> productInfoList = geProductInfoService.queryGeProductInfoByQueryRule(queryRule);
super.getRequest().setAttribute("productInfoList ", productInfoList );
}catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
<action name="hotGoods" class="listAction" method="hotGoods">
<result name="success" type="chain">hotGoods1</result>
</action
public String hotGoods1() {
try {
List<ProductInfo> productInfoList = (List<ProductInfo>)super.getRequest().getAttribute("productInfoList ");
super.getRequest().setAttribute("productInfoList ", productInfoList );
} catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
<action name="hotGoods1" class="listAction" method="hotGoods1">
<result name="success">index.jsp</result>
</action>
index.jsp可以得到productInfoList 的值
二、result:redirect(从一个Action转发到另一个Action)
public String getFamilyCardUrl() {
try {
familyCardWeixinURL = “*****”;
//familyCardWeixinURL内容为*****.getFamilyCardOpenId.do?code=code&****
return "familyCardWeixinURL";
} catch (Exception e) {
e.printStackTrace();
}
return "fail";
}
<action name="getFamilyCardOpenId" class="**Action" method="getFamilyCardOpenId">
<result name="familyCardWeixinURL" type="redirect">${familyCardWeixinURL}</result>
<result name="fail" type="redirect">/common/500Phone.jsp</result>
</action>
getFamilyCardOpenId所在action中需要有全局变量familyCardWeixinURL及其get,set方法
//未完成
关注公众号:CS尼克。我们一起学习计算机相关知识
struts2 result随笔的更多相关文章
- struts2 Result Type四个常用转跳类型
Result的四个常用转跳类型分别为 Dispatcher 用来转向页面,是Struts的默认形式 Redirect 重定向到一个URL Chain 用来处理Action链 RedirectAc ...
- Struts2(result 流 )下载
jsp: <body> <a href="stream.action?fileName=psb.jpg">psb</a> <br> ...
- struts2 result type类型
result标签中type的类型 类型 说明 chain 用于Action链式处理 dispatcher 用于整合JSP,是<result>元素默认的类型 freemarket 用来整合F ...
- Struts2 result type(结果类型)
转自:http://www.cnblogs.com/liaojie970/p/7151103.html 在struts2框架中,当action处理完之后,就应该向用户返回结果信息,该任务被分为两部分: ...
- Struts2 result type
Struts2支持的不同类型的返回结果为: type name 说明 dispatcher 缺省类型,用来转向页面,通常处理JSP chain 转向另一个action,用来处理Action链 redi ...
- struts2 result的type属性
目前只使用过以下3种,都是直接跳转到另一个action chain: 写法:<result name="success" type="chain"> ...
- struts2 result type的类型
一共十种类型 1.dispatcher 默认的类型,相当于servlet的foward,服务器端跳转.客户端看到的是struts2中配置的地址,而不是真正页面的地址.一般用于跳转到jsp页面 2.re ...
- struts2 result type属性说明
首先看一下在struts-default.xml中对于result-type的定义: <result-types><result-type name="chain" ...
- 分享知识-快乐自己:Struts2 - result标签的name属性和type属性
1):result的name属性 例如:<result name="success">/pages/success.jsp</result> Strut ...
随机推荐
- 华为轮值CEO,富士康却坚持独裁,二者究竟有什么不一样?
谈到深圳龙华的大企业,人们会很自然地想到华为和富士康,两家公司毗邻,有两个门仅仅隔着一条马路,都是世界500强,对国家,对社区的经济发展有着重要贡献,员工压力最大的时候,也都出现过自杀的情况,一个讲究 ...
- windows10更换mysql8.0.17
下载windows版本mysql 解压后创建my.ini文件初始化mysql和data文件夹用来存数据 my.ini内容 [mysqld] # 设置3306端口 port=3306 # 设置mysql ...
- 仿有道词典App开发
最近在学习HCoder提供的仿有道词典App项目,该项目采用MUI为前端框架,服务端采用PHP,底层采用了H5+.
- MySQL多实例安装(相同版本)
本文以MySQL5.7为例,介绍在同一台机器下如何安装多个MySQL实例. 环境:RHEL 6.5 + MySQL 5.7 1.单实例MySQL安装 2.多实例MySQL配置 3.多实例MySQL初始 ...
- 「CF1039D」You Are Given a Tree
传送门 Luogu 解题思路 整体二分. 的确是很难看出来,但是你可以发现输出的答案都是一些可以被看作是关键字处于 \([1, n]\) 的询问,而答案的范围又很显然是 \([0, n]\),这不就刚 ...
- 「UVA10559」Blocks
传送门 Luogu 解题思路 考虑区间 \(\text{DP}\). 设 \(f[i][j][k]\) 表示 \([i,j]\) 这段区间接上后面 \(k\) 个与 \(j\) 颜色相同的块得到的答案 ...
- Spring Boot 学习(一)
转载资料 spring boot快速入门 https://www.cnblogs.com/wmyskxz/p/9010832.html spring boot 入门篇 https://www.cnbl ...
- Ubuntu下使用mail命令发送邮件
Ubuntu下使用mail命令发送邮件 mail命令在Ubuntu下是需要安装的,使用下条命令进行安装: sudo apt-get install heirloom-mailx 接下来输入用户密码,等 ...
- 编程题目 定义栈的数据类型,请在类型中实现一个能够得到栈最小元素的minx函数。
首先自己用 节点 实现了 栈 这种数据类型 为了实现题目了要求,我使用的两个栈. 一个栈 用来 push pop 用户的数据, 另外一个栈用来存放 最小元素(涉及元素比较) 代码如下: #!/usr/ ...
- Spark Scheduler 模块(下)
Scheduler 模块中最重要的两个类是 DAGScheduler 和 TaskScheduler.上篇讲了 DAGScheduler,这篇讲 TaskScheduler. TaskSchedule ...