参考:

http://struts.apache.org/2.0.11/docs/result-annotation.html

http://jdkcn.com/entry/add-params-to-struts2-result-annotation.html

在原来的webwork式的xml配置文件里可以给<action>下的<result>节点添加一些额外的参数。
<result ..>
      <param name="">...</param>
</result>
那换成@Result annotation之后要怎么做呢。

看@Result的源代码发现有个params的String数组

@Retention(RetentionPolicy.RUNTIME)
public @interface Result {
    String name() default Action.SUCCESS;
    Class type() default NullResult.class;
    String value();
    String[] params() default {};
}

可是原来的param配置是个key和value的键值对啊。后来查到struts2的文档原来就这个String数组里约定的是key,value,这样的顺序。

  • params - An Array of the parameters in the form {key1, value1, key2, value2}

@Result(name="error",type=FreemarkerResult.class, value="/error.ftl", params={"contentType", "application/xml"})

传参数呢?

@Result(name="success",
  type="redirectAction",
  location="d-list",
  params={"id", "%{id}""}
)

这样,当return SUCCESS时,就会跳转至d-list?id=XXXX

struts2的@Result annotation 如何添加params的更多相关文章

  1. struts2的@Result annotation 如何添加params,并且在页面取值

    http://www.bubuko.com/infodetail-2492575.html .............................................. 标签:lai  ...

  2. Struts2 配置文件result的name属性和type属性

    Struts2 配置文件result的name属性和type属性:Name属性SUCCESS:Action正确的执行完成,返回相应的视图,success是 name属性的默认值: NONE:表示Act ...

  3. Struts2 自定义Result

    注意:我只要是解决自定义返回Json 和异常处理问题 新建一个类 AjaxResult   继承 StrutsResultSupport 看看代码吧 public class AjaxResult e ...

  4. Struts2中基于Annotation的细粒度权限控制

    Struts2中基于Annotation的细粒度权限控制 2009-10-19 14:25:53|  分类: Struts2 |  标签: |字号大中小 订阅     权限控制是保护系统安全运行很重要 ...

  5. Struts2之Result详解

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

  6. Caused by: The Result type [json] which is defined in the Result annotation on the class

    1.错误描述 严重: Dispatcher initialization failed Unable to load configuration. - [unknown location] at co ...

  7. struts2的result的类型配置简介

    一.在strut2的action处理完成后,就应该向用户返回结果信息result 根据以下代码作为实例分析: <package name="Hello" extends=&q ...

  8. Struts2 中result type属性说明

    Struts2 中result type属性说明 首先看一下在struts-default.xml中对于result-type的定义: <result-types><result-t ...

  9. struts2 action result type类型

    struts2 action result type类型 1.chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息. com.opensymphony. ...

随机推荐

  1. Oracle 存储过程实例

    create or replace procedure PCREPORT is startDate DATE; --起始如期 nowTime DATE; --当前日期 nowTime2 DATE; - ...

  2. BitmapSource ConvertTo Bitmap

    偶遇需要把 BitmapSource 转成 Bitmap. .. using System; using System.Drawing; using System.Drawing.Imaging; u ...

  3. [转载]C# FTP操作工具类

    本文转载自<C# Ftp操作工具类>,仅对原文格式进行了整理. 介绍了几种FTP操作的函数,供后期编程时查阅. 参考一: using System; using System.Collec ...

  4. 文字沟通工具使用SignalR,跨域例子源代码

    其他网站已经有很多关于SignalR的介绍了.这里不多介绍. 安装:Install-Package Microsoft.AspNet.SignalR -Version 1.1.4 参考自:http:/ ...

  5. html+css学习笔记 [基础1]

    ---------------------------------------------------------------------------------------------------- ...

  6. 2875: [Noi2012]随机数生成器 - BZOJ

    DescriptionInput 包含6个用空格分割的m,a,c,X0,n和g,其中a,c,X0是非负整数,m,n,g是正整数. Output 输出一个数,即Xn mod gSample Input ...

  7. 3144:[HNOI2013]切糕 - BZOJ

    题目描述 Description 经过千辛万苦小 A 得到了一块切糕,切糕的形状是长方体,小 A 打算拦腰将切糕切成两半分给小 B.出于美观考虑,小 A 希望切面能尽量光滑且和谐.于是她找到你,希望你 ...

  8. 剑指offer--面试题11

    题目:求数值的整数次方,不考虑大数值情况 即实现函数:double Power(double base, int exponent) 自己所写代码如下: #include "stdafx.h ...

  9. [转载]DirectoryEntry配置IIS7出现ADSI Error:未知错误(0x80005000)

    一.错误情况 环境:win7+iis7.0 DirectoryEntry配置IIS7出现如下错误 或者是 下面一段代码在IIS6.0下运转正常,但IIS7.0下运转会出错: System.Direct ...

  10. Ubuntu12.04 + 虚拟机VMware 9 + Secure CRT + EditPlus 本地C++开发环境搭建

    1.1  软件准备 虚拟机VMware 9 Ubuntu 12.04 Secure CRT EditPlus 1.2  安装VMware 9与Ubuntu 12.04 这两个软件安装,按部就班,这里就 ...