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 ...
随机推荐
- 学习SpringBoot零碎记录——配置应用URL名称
学习SpringBoot配置应用名称,结果发现坑 到网上找 到 https://blog.csdn.net/qq_40087415/article/details/82497668 server: p ...
- Lesson 5 Youth
How does the writer like to treat young people? People are always talking about 'the problem of yout ...
- SciPy 图像处理
章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...
- hdu 3549 Flow Problem 最大流问题 (模板题)
Flow Problem Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...
- python-python基础4
本章内容: 装饰器 生成器 迭代器 json & pickle 模块 软件目录结构规范 一.装饰器 装饰器 在不改动函数代码的基础上无限制扩展函数功能的一种机制,本质上讲,装饰器是一个返回函数 ...
- Deep Image Retrieval: Learning global representations for image search In ECCV, 2016学习笔记
- 论文地址:https://arxiv.org/abs/1604.01325 contribution is twofold: (i) we leverage a ranking framework ...
- JS - 判断字符串某个下标的值
<html><body> <script type="text/javascript"> var str="0123456789!&q ...
- Excel的查询函数vlookup和index使用
需求 有一些省市的区县,有600多条数据,只有名称,没有编码.现在要根据名称去3000多条数据里面查询. 如图,拿出一部分数据来演示 vlookup 使用vlookup,由于vlookup只能查询数据 ...
- 图形与动画在Android中的实现
public class MyView extends View{ Bitmap myBitmap; Paint paint; public MyView(Context context, Attri ...
- Day6 - 牛客203E
https://ac.nowcoder.com/acm/contest/203/E 埋坑不会做