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尼克。我们一起学习计算机相关知识
转载于:https://www.cnblogs.com/shueixue/p/5709954.html
struts2 result随笔相关推荐
- Struts2 Result详解
1,Result原理 1) Result组件是Struts2中用于输出的组件,实际上就是Java代码. 2)Struts2中预制了10中类型的Result,这些Result什么在struts-defa ...
- Struts2 Result 类型和对应的用法详解 2
转载于:https://www.cnblogs.com/navyhj/p/5851578.html
- Struts2的结果集
1.结果集的使用方式 struts结果集的使用分为三种,指定全局结果集.普通方式指定结果集合动态指定结果集. 1.1全局结果集 当许多action都有共同的结果时,如果每个package都存在一个相同 ...
- ssh(1)struts2
1.b/s框架 browser-servlet请求-响应的处理过程的集合体 2.MVC模式(持久层,表示层,业务逻辑层) M 数据模型(模型):作为程序的核心载体,用于传输数据(bean hiber ...
- JAVA代审之Struts2漏洞S2-057的调试分析
文章目录 前言 IDEA调试 环境搭建 漏洞验证 调试分析 漏洞修复 总结 前言 2018 年 8 月 23 日,Apache Strust2 发布最新安全公告,Apache Struts2 存在远程 ...
- struts2.3.32升级到struts2.5.26
下载struts2.5.26jar包 官网下载 更新jar 新增或替换 asm-7.3.1.jar asm-analysis-7.3.1.jar asm-commons-7.3.1.jar asm-t ...
- Struts2学习笔记
文章目录 Struts2 的核心开发包 Struts2 配置文件 Struts2 域对象 Struts2 编程流程 Action 组件 使用通配符配置 Action Action 中如何访问 Sess ...
- Struts2-result类型
Struts2 result类型 1.dispatcher:服务器跳转到页面,通常来处理JSP,默认类型. 2.redirect:重定向到页面. Action: 1 public String red ...
- Struts 拦截器
介绍 实现aop的方式 用于实现action之前,之后执行 一般用于事物操作. 一般用于对某些未授权的页面访问的时候,进行拦截操作,拦截非法访问. 开箱即用拦截器 <!-- 拦截器 --> ...
- Struts2 的stream result用法
2019独角兽企业重金招聘Python工程师标准>>> <action name="download" class="com.unmi.actio ...
最新文章
- php怎么新建页面,whmcs创建自定义页面,创建PHP访问页面方法
- VS2012 编译 boost1.53/ boost1.49
- 2020年计算机一级B押题,2021年全国计算机一级选择题真题押题.doc
- 强化学习Q-Learning算法及实现详解
- python数组类型_一文搞懂Python中的所有数组数据类型
- 江西职业教育集团计算机应用竞赛,【喜报】江西工业职院电子与信息工程学院学生在计算机应用竞赛钟喜获佳绩...
- c语言中的errno
- 商(quotient)—— 两数之比
- 【unity3d study ---- 麦子学院】---------- unity3d常用组件及分析 ---------- 组件的生命周期...
- 三极管构成的流水灯电路分析
- 控制系统分析与设计(三):非线性数学模型的线性化
- 北京冬奥会使用的集装箱最后如何处理
- 明天冬瓜哥与你见面畅谈!不用报名直接来!
- JZOJ5939. 【NOIP2018模拟10.30】阻击计划
- Spring5框架day01之IOC容器
- 台式机通过笔记本的WIFI上网
- mysql查询最近三个月数据方法
- python办公笔记分享
- 域名批量查询 网站域名批量查询
- KVM 虚拟化技术高级特性详解