在Struts 2:字符串数组传递静态参数 [英] Struts 2 : Passing array of String as static param

查看:190
本文介绍了在Struts 2:字符串数组传递静态参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我能通过静态参数的字符串阵列这样的方式来宣告一个动作。我想下面的code:

I wanted to declare an action in such a way that I could pass String array of static parameter. I tried the below code:

<action name="saveRecord" class="saveRecordAction">
        <result name="success" type="tiles">tiles:saveRecordSuccess</result>
        <param name="names">name1</param>
        <param name="names">name2</param>
        <param name="names">name3</param>
    </action>

我有一个二传手在我的动作类:

I have a setter in my action class:

public void setNames(String[] name){
    mNames = name;
}

不过,我只收到一个名称是最后一个,NAME3

是我想要的可能吗?如果有,是什么做的正确方法是什么?

Is what I wanted possible? if yes, what is the correct way of doing it?

推荐答案

的支柱静态参数的工作方式类似计划。名义键和值的价值。
您可以通过逗号分隔的,你可以把它分解,这样你可以有你的阵中还有发送的值达到您的要求。

The struts static param works like MAP. name been the KEY and value as VALUE. You can achieve your requirement by sending the values as comma separated and you can split it so that you can have your array there.

<param name="names">name1,name2,name3</param>

有关静态参数

这篇关于在Struts 2:字符串数组传递静态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆