result 相关
1.dispatcher
2.redirect
3.chain
4.redirectAction
5.freemarker
6.httpheader
7.stream
8.velocity
9.xslt
10.plaintext
11.tiles
常用的是前四种
<package name="resultType" namespace="/r" extends="struts-default">
<action name="r1">
<!-- result 不指定type默认为dispatcher 运用服务器跳转 forword到jsp压面 显示action地址 -->
<result type="dispatcher">/r1.jsp</result>
</action>
<action name="r2">
<!-- 客户端跳转 显示jsp地址 -->
<result type="redirect">/r2.jsp</result>
</action>
<!-- 同r1 forword到另外一个action -->
<action name="r3">
<result type="chain">r1</result>
</action>
<!-- 同r2 -->
<action name="r4">
<result type="redirectAction">r2</result>
</action>
</package>
<package name="user2" namespace="/user2" extends="struts-default">
<!-- 其他包可以用extends继承 -->
<global-results>
<result name="mainpage">/main.jsp</result>
</global-results>
<action name="user2" class="com.ouc.wkp.action.UserAction2">
<result name="success">/r1.jsp</result>
<result name="error">/r2.jsp</result>
</action>
</package>
<package name="user3" namespace="/user3" extends="struts-default">
<action name="user3" class="com.ouc.wkp.action.UserAction3">
<result>${r}</result>
</action>
</package>
struts.xml
package com.ouc.wkp.action;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction2 extends ActionSupport {
private int type;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@Override
public String execute() throws Exception {
if(type==1){
return "success";
}else if(type==2){
return "error";
}else{
return "mainpage";
}
}
}
UserAction2
package com.ouc.wkp.action;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction3 extends ActionSupport {
private int type;
private String r;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getR() {
return r;
}
public void setR(String r) {
this.r = r;
}
@Override
public String execute() throws Exception {
if (type == 1) {
r = "/r1.jsp";
} else if (type == 2) {
r = "/r2.jsp";
} else {
r = "/main.jsp";
}
return SUCCESS;
}
}
UserAction3
使用redirect跳转时是两次request,需要传参
<!-- <result type="redirect">/xxx.jsp?t=${type}</result> -->
前台通过<s:property value="#parameters.t"/>从actioncontext里面取
result 相关的更多相关文章
- 【原创】7. MYSQL++中的查询结果获取(各种Result类型)
在本节中,我将首先介绍MYSQL++中的查询的几个简单例子用法,然后看一下mysqlpp::Query中的几个与查询相关的方法原型(重点关注返回值),最后对几个关键类型进行解释. 1. MYSQL++ ...
- 你从未知道如此强大的ASP.NET MVC DefaultModelBinder
看到很多ASP.NET MVC项目还在从request.querystring或者formContext里面获取数据,这实在是非常落后的做法.也有的项目建了大量的自定义的modelbinder,以为很 ...
- 大批量GPS坐标转百度坐标
一. 百度地图API大批量转换时有数量限制,一个一个转. 用到的方法接口 /** 源坐标 格式:经度,纬度;经度,纬度… 最多支持100个; 源坐标类型:默认为1,即GPS ...
- Java日期格式化
翻译人员: 铁锚 翻译时间: 2013年11月17日 原文链接: Simple example to show how to use Date Formatting in Java 代码示例如下, ...
- Jquery Ajax方法传递json到action
ajax向后台传入json需要设置option,如下 contentType:'application/json' data:Json.Stringify(jsObj) 后台处理复杂json对象(不知 ...
- 12.06 JavaScript
任务 掌握JavaScript基础知识,能够使用JavaScript编写一些复杂度不大的交互功能. 任务: JavaScript基础 做完任务一的时候深深地感觉到自己的基础非常的薄弱,在这里再次感谢一 ...
- asp.net core mvc剖析:动作执行
紧跟上一篇文章.通过路由和动作匹配后,最终会得到跟当前请求最匹配的一个ActionDescriptor,然后通过IActionInvoker执行动作. 我们先来看一下IActionInvoker如何得 ...
- HashMap源码详解(JDK7版本)
一.内部属性 内部属性源码: //内部数组的默认初始容量,作为hashmap的初始容量,是2的4次方,2的n次方的作用是减少hash冲突 static final int DEFAULT_INITIA ...
- 基于Metronic的Bootstrap开发框架经验总结(15)-- 更新使用Metronic 4.75版本
在基于Metronic的Bootstrap开发框架中,一直都希望整合较新.较好的前端技术,结合MVC的后端技术进行项目的开发,随着时间的推移,目前Metronic也更新到了4.75版本,因此着手对这个 ...
随机推荐
- Enabling Process Accounting on Linux HOWTO
http://tldp.org/HOWTO/Process-Accounting/index.html
- 柯南君:看大数据时代下的IT架构(2)消息队列之RabbitMQ-基础概念详细介绍
一.基础概念详细介绍 1.引言 你是否遇到过两个(多个)系统间需要通过定时任务来同步某些数据?你是否在为异构系统的不同进程间相互调用.通讯的问题而苦恼.挣扎?如果是,那么恭喜你,消息服务让你可以很轻松 ...
- Android之条码扫描二维码扫描
Android之条码扫描二维码扫描 二维码条形码扫描,参考技术网址: 1.Apache License 2.0 开源的ZXing项目的简化版 http://xinlanzero.iteye.com/b ...
- BZOJ 1179 [Apio2009]Atm(强连通分量)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1179 [题目大意] 给出一张有向带环点权图,给出一些终点,在路径中同一个点的点权只能累 ...
- C# OR/Mapping 数据处理模式学习
为什么要提出O/R Mapping概念 程序语言已经由面向过程的模型全面转向为面向对象的模型,UML的出现更加革新了软件开发方法论.然而数据库模型却从未随着开发语言的进步而随之革新,仍然使用面向关系的 ...
- prototype演变
setp1 var Person = function () {}; //构造器 var p = new Person(); setp1 演变: var Person = function () {} ...
- html基础标签-1-pre预格式标签
pre预格式标签 code,tt标签 1 <!doctype html> 2 <html lang='zh-cn'> 3 <head> 4 <meta cha ...
- SGU 134.Centroid( 树形dp )
一道入门树dp, 求一棵树的重心...我是有多无聊去写这种题...傻X题写了也没啥卵用以后还是少写好.. ----------------------------------------------- ...
- Centos6.4 搭建Git服务器 (最简单的方法)
下载 git-1.8.2.tar.gz tar -zvxf git-1.8.2.tar.gz cd git-1.8.2.2 sudo make prefix=/usr/local/git all su ...
- robot framework环境搭建和简单示例
环境搭建 因为我的本机已经安装了python.selenium.pip等,所以还需安装以下程序 1.安装wxPythonhttp://downloads.sourceforge.net/wxpytho ...