這裏是情況。Struts問題;使用相同的動作來顯示並提交
我有一個頁面叫做param.jsp
,它只有一個表單和一個提交按鈕。數據庫中有一條記錄,當表單呈現時,我想用該記錄填充表單。提交表單時,我想更新該單個記錄並返回到同一頁面。在struts中執行此操作的最佳方法是什麼?
到目前爲止,我已經想出了這個;這裏是動作:
class MyAction extends DispatchAction{
public ActionForward savePlatinumJLParam(......){
//<insert the form to the database>
return mapping.findForward("<return to the same page>");
}
public ActionForward initPlatinumJLParam(......){
//<load the form from the database>
//form.setXX(...);
return mapping.findForward("<return to the same page>");
}
}
節能工作得很好,但我有與填充表格的麻煩。任何幫助表示讚賞。
感謝您的回答,但這正是我所做的,並沒有奏效。我一定會錯過一些東西,我會嘗試你以後提供的這個例子併發布結果。 – 2010-11-01 17:57:17
你得到了什麼異常? – 2010-11-01 18:02:44
我沒有收到任何異常,表單字段呈現爲空。 – 2010-11-02 06:05:26