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 ...
随机推荐
- English_Rhymes_Phonics_resource
English_Rhymes_Phonics_resource 1. 英语启蒙早有用吗?_英语启蒙 2. 26个英文字母背后的故事_英语启蒙 3. Phonics Song 4. 学Phonics前先 ...
- 跳蚤[BZOJ4310](后缀数组+二分答案传判定)
不知道后缀数组的请退回去! 题面: 题目描述 很久很久以前,森林里住着一群跳蚤.一天,跳蚤国王得到了一个神秘的字符串,它想进行研究.首先,他会把串分成不超过 k 个子串,然后对于每个子串 S,他会从S ...
- java web开发缓存方案,ehcache和redis哪个更好
Ehcache在java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS中取出来的高花费.高延迟采取的一种缓存方案.正因为Ehcache具有健壮性(基于java开发).被认证(具有apac ...
- java 之word转html
jar包 链接: https://pan.baidu.com/s/13o2CZTwM-Igx6wcoyEu_ug 密码: n95q package com.bistu.service; import ...
- 2017 青岛网络赛 Chenchen, Tangtang and ZengZeng
Chenchen, Tangtang and ZengZeng are starting a game of tic-tac-toe, played on a 3 × 3 board. Initial ...
- Ubuntu操作系统编写zabbix的启动管理脚本
Ubuntu操作系统编写zabbix的启动管理脚本 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.修改zabbix的pid存放路径 1>.创建存放zabbix的pid目录 ...
- 第1节 IMPALA:6、yum源制作过程
impala的安装:第一步:下载5个G的安装包,并且上传linux,解压第二步:安装httpd的服务,并启动,访问httpd就是访问我们linux的 /var/www/html这个路径下面的东西第三步 ...
- 第1节 IMPALA:2、架构介绍
impala的架构以及查询计划: impalad :从节点 对应启动一个impala-server的进程 ,主要负责各种查询计划,官方建议与所有的datanode安装在同一台机器上面 impala-s ...
- 编程题目: 找出最小的k个数
找出最小或者最大的几个数我使用的是堆排序,效率为0(nlgn) 构建小顶堆返回末尾的k个数 或者 构建大顶堆返回前k个数 #!/usr/bin/env python3 def heap_sort(ar ...
- Python 常用的标准库以及第三方库有哪些?
作者:史豹链接:https://www.zhihu.com/question/20501628/answer/223340838来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...