2

私はそれをやろうとしています

  1. アクションでデータベースからオブジェクトのリストを取得する (OK)
  2. JSPに印刷する(OK)
  3. このリストは、JSP で編集可能なテーブルとして表示されます。変更した後、同じアクションに送信してデータベースに保存したい (FAIL。 <s:submit action="myaction" method="mymethod">以前にデータベースから入力したリストを使用してメソッドを呼び出すと、現在はnull.どうすれば解決できますか?

リフレクションでデータを注入する struts2 インターセプターについて話しているトピックを見つけました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>

基本的に、顧客を表示するために反復する必要があり、顧客ごとに作業時間がかかります。次に、1時間ごとに編集してDBに保存する可能性があるはずです

4

2 に答える 2