简体   繁体   English

如何从jsp检索String []数组以使用Struts2进行操作?

[英]How to retrieve an array of String[ ] from jsp to action with Struts2?

I've some logic problem with Struts2, i'm trying to pass an array of Strings from jsp to an Action, the problem is that, when i try to pass this Strings in an ArrayList it goes well, i can see datas, when i try with the same names and values, to pass the value into a String[], the value it's just null, where i'm doing wrong? 我在Struts2中遇到了一些逻辑问题,我正在尝试将字符串数组从jsp传递到Action,问题是,当我尝试在ArrayList中传递此字符串时,它运行良好,可以看到数据,何时我尝试使用相同的名称和值,将值传递给String [],该值只是null,我在哪里做错了?

That's my Action: 那是我的行动:

 public class EscludiElementoRicercaMagazzinoAction extends MyActionSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 7627908677897902673L;
    private static Logger                   logger              =           Logger.getLogger(EscludiElementoRicercaMagazzinoAction.class);
    String[] selezionato;



    public String[] getSelezionato() {
        return selezionato;
    }




    public void setSelezionato(String[] selezionato) {
        this.selezionato = selezionato;
    }



    @Override
    public String execute() throws Exception {
        logger.debug("inizio");
        //TODO DA FINIRE
        MovimentazioneMagazzino.escludiMagazzino(selezionato);
        logger.debug("fine");
        return SUCCESS;
    }
}

And that's how i send data to action... 这就是我发送数据以采取行动的方式...

<input type="hidden" value="54" name="selezionato[0]" class="hiddenModaleEscludiElemento">

Just remove the index in your input like this: 只需像这样删除输入中的索引:

<input type="hidden" value="54" name="selezionato" class="hiddenModaleEscludiElemento">

Hope this would help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM