我非常恼火的下列问题。我是Struts2的初学者。 我试图做到这一点Struts2动作> jsp>动作
- 获取对象的列表从数据库中我的行动(OK)
- 打印它JSP(OK)
- 这份名单出来作为JSP可编辑表..我想修改,然后提交回相同的行动,以将其保存在我的数据库(失败。当我打电话给我的方法与
<s:submit action="myaction" method="mymethod">
列表我以前从db填充现在是null.How我可以解决吗?
我发现一些话题谈论支柱s2拦截器用myaction
反射注入数据。
public class CurrentOra {
private int idCommessa;
private String descrizioneCommessa;
private int idCliente;
private String descrizioneCliente;
private List<OreTimesheetGiorno> orePerCommessa;
public int getIdCommessa() {
return idCommessa;
}
}
和
public class OreTimesheetGiorno {
private int numeroGiorno;
private OreTimesheet oreTimesheet;
public int getNumeroGiorno() {
return numeroGiorno;
}
public void setNumeroGiorno(int numeroGiorno) {
this.numeroGiorno = numeroGiorno;
}
public OreTimesheet getOreTimesheet() {
return oreTimesheet;
}
public void setOreTimesheet(OreTimesheet oreTimesheet) {
this.oreTimesheet = oreTimesheet;
}
}
这是我的对象结构,并在JSP我
<s:iterator value="listOre" >
<tr class="giornoSettimana giornoUno">
<td><s:property value="descrizioneCliente"/></td>
<td><s:property value="descrizioneCommessa"/></td>
<s:iterator value="orePerCommessa">
<td>
<input type="text"
class="oreConsuntivazione"
maxlength="2"
giorno = "<s:property value="numeroGiorno" />"
value="<s:property value="oreTimesheet.numeroOre" />">
</td>
</s:iterator>
</tr>
</s:iterator>
基本上我需要遍历向客户展示,并为每一位客户每小时打印处理它。然后,我应该可以编辑每个小时并将其保存回分区
当然'List'是'null' - 你的动作在每一个传入请求中重新产生。您需要从网页返回一些_something_以告诉操作要删除的内容。 [This](http://code.google.com/p/struts2-jquery/wiki/EditGrid)应该给你一个出发点。 –
请注意:从页面上的表单提交时,所有表单元素都包含在请求中。这意味着如果你想从表单提交信息,它必须存储在表单中的表单元素中。把你的清单放在表格中。 – DwB
Ofc我试图提交的所有字段都在表单内。我只在列表中遇到问题。从jsp> action传入输入没有任何问题。我只有当我用 cuz打印一个列表时,才会出现问题标签迭代器没有名称属性来绑定请求并发回操作.. –
Federik