簡體   English   中英

在struts2框架中,DTO由列表組成 <String> 。 它沒有從S:select標記填充

[英]In struts2 framework, DTO consists of list<String>. Its not getting populated from S:select tag

我是struts2的新手,並且查看現有代碼和網絡中的其他內容,我認為下面的代碼應該可以工作。 我正在嘗試在JSP的s:select框中選擇一些用戶ID,我想在我的操作類中使用這些ID。 我正在使用modelDriven,用戶在列表中

JSP代碼段

<s:select id="selectedAgents" 
          name="selectedUserList"
          multiple="true"               
          list="selectedUserList"
 />

頁面中選定的用戶ID進入此框。 當提交表單時,我希望看到selectUserList處於運行狀態。

在行動中,我有

public class WorkLoadReportAction extends GenericAction implements ModelDriven<WorkloadReportDTO> 
...

private WorkloadReportDTO userReportInputData = new WorkloadReportDTO();

...
@Override
    public WorkloadReportDTO getModel() {
        return userReportInputData;
    }

WorkloadReportDTO具有List<String> selectedUserList以及其getter和setter。

現在在該動作的方法(從submit中調用)中,我看不到selectedUserList填充。

我想念什么?

在您的Jsp中:

<s:select id="selectedAgents" 
      name="selectedUserList"
      multiple="true"               
      list="selectedUserList"

/>

您具有相同的name attribute值和list attribute值。 嘗試更改name attributelist attribute

希望這能解決您的問題

暫無
暫無

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

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