struts2里面取action传过来的list值

新手上路,请多包涵
tag 'select', field 'list', name 'departmentId': The requested list key '#departments' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name}

下面上代码:

    public String toAddPage() {
    
        List<Department> departments = departmentService.findAll();
        List<Role> roles = roleService.findAll();
        
        ActionContext.getContext().put("departments", departments);
        ActionContext.getContext().put("roles", roles);
        return "toEditPage";
    }
                    <tr>
                        <td width="100">所属部门</td>
                        <td>
                            <s:select name="departmentId" list="#departments" 
                                      listKey="dId" listValue="dName" headerKey=" " headerValue="请选择部门" cssClass="SelectStyle" >
                            </s:select>
                        </td>
                    </tr>

求高手解答,谢谢

阅读 3.2k
1 个回答

你这个错误是说这集合不能被解析,有可能是集合是空的,没查到数据。你打印下集合或者debug,看看集合到底有没数据

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题