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-phoneme
1. 声音概述 2. 音素phoneme与音标 2.1 音素与音标 2.2 音素与字母 2.3 字母发音-字母自然发音对照表 2.4 音标表 2.5 元音字母-辅音字母表 2.6 单元音发音口形趋势表 ...
- java学习-循环结构-查找算法-顺序查找
今天回顾了简单算法,顺序查找.发现了数组出现重复数字,无法输出第二个位置就跳出循环了. 利用所学知识解决了.放上代码,同时在代码里给大家分享思路. 欢迎大神教导,欢迎指正. ; System.out. ...
- 使用 XMLBeans 进行编程
深入考察 XMLBeans 的特性和功能.本文通过一个简单的例子介绍 XMLBeans 技术,然后一步一步地介绍编译和绑定的过程,讨论 XML 游标.标记和 XQuery 表达式等高级特性.本文还 ...
- STL访问Map问题,key为Integer或Long
参考stackoverflows上的这篇文章 http://stackoverflow.com/questions/924451/jstl-access-a-map-value-by-key 换成 原 ...
- Python协程理解——基于爬虫举例
当前代码在工作当中没有太大的含义,但是对于大家理解协程的基础概念是相当有好处的协程最直接的可以理解为程序当中一个没有返回的功能块儿我们之前有学过多线程,所谓的多线程不论是异步并发,还是并发强调的时候将 ...
- IP 和 IP地址的区别和联系
IP(internet protocol) 网际协议 和IP地址有人会把“IP”和“IP 地址”搞混,“IP”其实是一种协议的名称.IP 协议的作用是把各种数据包传送给对方.而要保证确实传送到对方那里 ...
- MAC 终端编辑完成后如何保存:
如果是vi,则:Esc 退出编辑模式,输入以下命令: :wq 保存后退出vi,若为 :wq! 则为强制储存后退出(常用):w 保存但不退出(常用):w! 若文件属性为『只读』时,强制写入该档案:q 离 ...
- 2019 OI日记
// 我觉得记日记是个好习惯吧 毕竟指不定哪天就学不下去了 就AFO了 就没有梦了 // [置顶]活跃于你谷普及训练场.ybt(没底气说全部).loj(提高基础部分) //优先级从前往后 因为 ...
- PHP截取指定字符前的字符串
$str = 'A|B||C|D'; echo substr($str,0,strpos($str, '||')); 输出:A|B
- WinForm_UI设计
下载