簡體   English   中英

將bean從動作映射到struts2中的表單

[英]Mapping bean from action to a form in struts2

我使用ModelDriven將參數從表單( value=username, fullname,... )填充到Action中的bean(名為user的bean)中。 我該如何從動作到表單執行同樣的操作(查看仍為value=username, fullname,...而不是user.username, user.fullname, ...

  • search.jsp只需獲取txtSearch並提交以查看操作。

  • ViewAction使用txtSearch從數據庫獲取數據,並使用UserDTO(ViewAction的屬性)進行保存

    / *我不知道如何將屬性映射到此view.jsp * /

  • view.jsp

     <s:form action="update" method="post"> <s:textfield label="Book Id" name="username" value="%{username}"> </s:textfield> <s:textfield label="Book Title" name="fullname" value="%{fullname}"> </s:textfield> <s:submit label="Update"></s:submit> </s:form> 
  • 通過上面的更新操作,結果返回到view.jsp

經過幾天的等待,我發現了兩種方法:

 1. set refreshModelBeforeResult param of ModelDriven interceptor to true

 2. ActionContext.getContext().getActionInvocation().getStack().push(user);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM