关于Sudo的一些提示 同步你的subversion repository
Apr 02

在原来的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"})
参数这里:http://struts.apache.org/2.0.11/docs/result-annotation.html


Like others

One Responses to “struts2的@Result annotation 如何添加params”

  1. ylgmguft Says:

     xzfenrcc http://fmgoatuf.com okhgzhkt jatzucut  [URL=http://gbgnraal.com]oghthobh[/URL]  <a href="http://cklhgbvc.com">hsdtreng</a> 

Leave a Reply

Identifying Code