struts2的@Result annotation 如何添加params
参考:
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 ..>那换成@Result annotation之后要怎么做呢。
<param name="">...</param>
</result>
看@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的更多相关文章
- struts2的@Result annotation 如何添加params,并且在页面取值
http://www.bubuko.com/infodetail-2492575.html .............................................. 标签:lai ...
- Struts2 配置文件result的name属性和type属性
Struts2 配置文件result的name属性和type属性:Name属性SUCCESS:Action正确的执行完成,返回相应的视图,success是 name属性的默认值: NONE:表示Act ...
- Struts2 自定义Result
注意:我只要是解决自定义返回Json 和异常处理问题 新建一个类 AjaxResult 继承 StrutsResultSupport 看看代码吧 public class AjaxResult e ...
- Struts2中基于Annotation的细粒度权限控制
Struts2中基于Annotation的细粒度权限控制 2009-10-19 14:25:53| 分类: Struts2 | 标签: |字号大中小 订阅 权限控制是保护系统安全运行很重要 ...
- Struts2之Result详解
上一篇我们把Struts2中的Action接收参数的内容为大家介绍了,本篇我们就一起来简单学习一下Action的4种Result type类型,分为:dispatcher(服务端页面跳转):redir ...
- 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 ...
- struts2的result的类型配置简介
一.在strut2的action处理完成后,就应该向用户返回结果信息result 根据以下代码作为实例分析: <package name="Hello" extends=&q ...
- Struts2 中result type属性说明
Struts2 中result type属性说明 首先看一下在struts-default.xml中对于result-type的定义: <result-types><result-t ...
- struts2 action result type类型
struts2 action result type类型 1.chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息. com.opensymphony. ...
随机推荐
- 日志文件切割服务logrotate配置及crontab定时任务的使用
1.下载logrotate 在Fedora和CentOS安装 yum install logrotate crontabs Debian和Ubuntu上 apt-get install logrota ...
- Ubuntu下安装eclipse及PyDev插件注意事项
一.安装eclipse前一定要先安装jdk 1.到http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880 ...
- 常见的装置与其在Linux当中的档名
需要特别留意的是硬盘机(不论是IDE/SCSI/U盘都一样),每个磁碟机的磁盘分区(partition)不同时, 其磁碟档名还会改变呢!下一小节我们会介绍磁盘分区的相关概念啦!需要特别注意的是磁带机的 ...
- Linux 命令整理 —— 用户管理
Linux用户管理以读.写.执行动作为权限,以用户组为单位,限制用户行为.对于文件的的操作,可以限制读.写.执行中的哪一种,也可以限制文件所有者.组用户.组外用户相应的权限. 所以,要建立用户,最好先 ...
- _beginthreadex创建多线程详解
一.需要的头文件支持 #include <process.h> // for _beginthread() 需要的设置:ProjectSetting-->C/C++- ...
- uva 10912
dp 记忆化搜索 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> ...
- Mac和iOS开发资源汇总
小引 本文主要汇集一些苹果开发的资源,会经常更新,建议大家把这篇文章单独收藏(在浏览器中按command+D). 今天(2013年7月19日)收录了许多中文网站和博客.大家一定要去感受一下哦. 如果大 ...
- Lua 的数据结构
1. Arrays: 注意 #(data), # 加上 table名字 == size of data = {}; , do --行 , do --列 data[(y-)*+x] = (y-)*+x; ...
- What is the difference between supervised learning and unsupervised learning?
Machine Learning is a class of algorithms which is data-driven, i.e. unlike "normal" algor ...
- 暑假集训单切赛第一场 CF 191A Dynasty Puzzles
题意不说了,看原题吧,思路见代码: #include <iostream> #include <stdio.h> #include <string.h> #incl ...