${r} : 表示配置文件xml可以读取action的valuestack的内容

1. jsp显示文件:

<body>
动态结果
一定不要忘了为动态结果的保存值设置set get方法
<ol>
<li><a href="user/user?type=1">返回success</a></li>
<li><a href="user/user?type=2">返回error</a></li>
</ol>
</body>

2. struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default"> <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
<result>${r}</result>
</action>
</package> </struts>

3. action:

package com.bjsxt.struts2.user.action;

import com.opensymphony.xwork2.ActionSupport;

public class UserAction extends ActionSupport {
private int type;
private String r;
public String getR() {
return r;
}
public void setR(String r) {
this.r = r;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@Override
public String execute() throws Exception {
if(type == 1) r="/user_success.jsp";
else if (type == 2) r="/user_error.jsp";
return "success";
} }

  

 

 

Struts2--Dynamic Result动态结果集的更多相关文章

  1. struts result动态结果集 带参数的结果集

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC     &qu ...

  2. Struts2学习---result结果集

    这一章节主要介绍如何配置结果集,分为以下几个知识点: 结果集类型(result type) 全局结果集(global types) 动态结果集(dynamic type) 带有参数的结果集(type ...

  3. 【web开发学习笔记】Structs2 Result学习笔记(二)动态结果集

    Result学习笔记(二) - 动态结果集     动态结果 一定不要忘了为动态结果的保存值设置set get方法 第一部分:代码 //前端 <% String context = reques ...

  4. 全局结果集,带参数的结果集和动态结果集(struts2)

    全局结果集: 当许多action都有共同的结果时,如果每个package都存在一个相同结果,会使得struts.xml比较臃肿,所以使用全局的结果集.一个包内的全局结果集可以通过包的继承而被其它包使用 ...

  5. Struts2 语法--result type

    result type: dispatcher,redirect:只能跳转到jsp,html之类的页面,dispatcher属于服务器跳转, redirect属于客户端跳转 chain: 等同于for ...

  6. Struts2之Result详解

    上一篇我们把Struts2中的Action接收参数的内容为大家介绍了,本篇我们就一起来简单学习一下Action的4种Result type类型,分为:dispatcher(服务端页面跳转):redir ...

  7. Struts2深入之动态调用Action

    使用过Struts2的小伙伴们应该知道当我们的action的方法过多是如果需要通过Struts2框架进行运行,我们就必须在Struts2的配置文件Struts2.xml文件中配置多个action属性标 ...

  8. 04. struts2中Result配置的各种视图转发类型

    概述 <action name="helloworld" class="com.liuyong666.action.HelloWorldAction"&g ...

  9. Airbnb的动态kubernetes集群扩缩容

    Airbnb的动态kubernetes集群扩缩容 本文介绍了Airbnb的集群扩缩容的演化历史,以及当前是如何通过Cluster Autoscaler 实现自定义扩展器的.最重要的经验就是Airbnb ...

随机推荐

  1. Hadoop概论

    1.Hadoop核心项目:HDFS(分布式文件系统)和MapReduce(并行计算框架) 2.HDFS的架构 主从结构 主节点,只有一个:namenode(接受用户操作要求:维护文件系统的目录结构:管 ...

  2. away 3d的一些问题

    不能成功draw m3u8视频流问题: Texture2DBase.as return context.createRectangleTexture(_width, _height, Context3 ...

  3. c#高级编程

    1..net才程序编译经过2步.首先把源代码编译成IL,这个是在visual studio中编译,然后是IL编译成机器语言,这个是在程序执行的时候进行的.

  4. eclipse关联源码的方法

    1.在项目的libs目录下,新建一个android-support-v4.jar.properties文件 2.打开android-support-v4.jar.properties,编辑. 输入源码 ...

  5. 剑指offer青蛙跳台阶问题

    (1)一只青蛙一次可以跳上 1 级台阶,也可以跳上2 级.求该青蛙跳上一个n 级的台阶总共有多少种跳法. //递归方式  public static int f(int n) { //参数合法性验证 ...

  6. ASP:GB2312格式文本文件转换成UTF-8格式

    '-------------------------------------------------'函数名称:gb2utf_file'作用:利用AdoDb.Stream对象来把GB2312格式文本文 ...

  7. 网址组成与特殊ip小解

    网址 https://www.baidu.com:8010/a/html/a.html?tn=monline_3_dg#part1 注解: 网址= 当前url协议+域名+端口号+路径名+参数+hash ...

  8. ant 配置expdp and impap

    + 执行步骤: ant -f 1_exp_prod.xml copy file from prod to uat (maunule) ant -f  3_imp_uat.xml 附件: 1.1_exp ...

  9. pom 的scope标签分析

    一.compile:编译范围compile是默认的范围:如果没有提供一个范围,编译范围依赖在所有的classpath 中可用,同时它们也会被打包.而且这些dependency会传递到依赖的项目中. 二 ...

  10. C语言头文件

    最近在工作当中遇到了一点小问题,关于C语言头文件的应用问题,主要还是关于全局变量的定义和声明问题.学习C语言已经有好几年了,工作使用也近半年了,但是对于这部分的东西的确还没有深入的思考过.概念上还是比 ...