数据收集表单输入隐藏的Struts 2

时间:2014-03-06 10:54:04

标签: struts2 hidden-field data-collection

当我将数据从隐藏字段发送到操作时,我的问题就出现了。没有正确收集数据,结果页面收到以下消息:

  • 使用值'[Ljava.lang.String; @ 354c0a31'
  • 设置表达式'idplatos'时出错
  • 使用值'[Ljava.lang.String; @ 4786b9ce'
  • 设置表达式'idrestaurantes'时出错

在这种形式中,隐藏字段的值来自先前的查询,在查询表单中未包含的其他数据的同一页面上。这是表单的代码:

<s:form action="Detalles.action" namespace="/" method="POST">
        <s:hidden name="idplatos" value="idplatos"/>
        <s:hidden name="idrestaurantes" value="restaurante.idrestaurante"/>
        <s:submit key="detalles" align="center"/>
</s:form>

这是行动中的代码:

public class PlatoAction extends ActionSupport {

private ArrayList <Platos> detalles;
private int idplatos;
private int idrestaurantes;

public String execute() throws Exception {

    Platos plato = new Platos();
    Restaurantes restaurante = new Restaurantes();

    plato.setIdplatos(getIdplatos());
    restaurante.setIdrestaurantes(getIdrestaurantes());

    System.out.println("idpla");
    System.out.println("idpres");

InterfacePlatosDAO PlatosDAO = FactoriaDAO.getPlatosDAO("MySQL");
detalles = PlatosDAO.detallePlato(plato, restaurante);

return SUCCESS;
}

public ArrayList<Platos> getDetalles() {
    return detalles;
}

public void setDetalles(ArrayList<Platos> detalles) {
    this.detalles = detalles;
}

public int getIdplatos() {
    return idplatos;
}

public void setIdplatos(int idplatos) {
    this.idplatos = idplatos;
}

public int getIdrestaurantes() {
    return idrestaurantes;
}

public void setIdrestaurantes(int idrestaurantes) {
    this.idrestaurantes = idrestaurantes;
}
}

有什么问题?

0 个答案:

没有答案