【问题标题】:In struts2 framework, DTO consists of list<String>. Its not getting populated from S:select tag在struts2 框架中,DTO 由list<String> 组成。它没有从 S:select 标记中填充
【发布时间】:2014-01-26 10:54:25
【问题描述】:

我是 struts2 的新手,查看现有代码和网络中的其他地方,我认为下面的代码应该可以工作。我正在尝试在 JSP 的 s:select 框中选择一些用户 ID,并且我想在我的操作类中使用这些 ID。我正在使用 modelDriven 并且用户在列表中

JSP代码sn-p

<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&lt;String&gt; selectedUserList 及其 getter 和 setter。

现在在操作的方法中(从提交调用),我没有看到 selectedUserList 填充。

我错过了什么?

【问题讨论】:

  • 默认拦截器栈?
  • 你能发布一个模型的代码吗?
  • 正如我所提到的,我是新手。我不明白你的问题。能详细点吗?
  • @user2353827 我想见WorkloadReportDTO.java
  • @RomanC 我想他在回答我。 OP:您是否使用默认拦截器堆栈(您的包扩展了“struts-default”并且您尚未定义任何自定义拦截器堆栈)?​​

标签: java jsp struts2


【解决方案1】:

在你的 Jsp 中:

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

/>

您的 name attribute 值和 list attribute 值相同。尝试更改 name attributelist attribute 的值。

希望这能解决您的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多