我非常惱火的下列問題。我是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