【发布时间】:2011-04-25 04:34:03
【问题描述】:
我不断收到以下 struts 错误:
描述服务器遇到了一个内部错误(),导致它无法完成这个请求。
异常
org.apache.jasper.JasperException: tag 'select', field 'list', name 'dept': The requested list key 'deptList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
。 . .
这是我的 .jsp 文件中的代码:
<s:select name="dept" list="deptList" listKey="deptId" listValue="deptString" headerKey="0" headerValue="Select a Department"
label="Select Department" />
这是我的操作文件中的代码(我通过调试验证它返回正确的值):
@Override
public String execute() throws Exception {
org.springframework.web.context.ContextLoaderListener c = new org.springframework.web.context.ContextLoaderListener();
EmployeeDao dao = (EmployeeDao) ContextLoader.getCurrentWebApplicationContext().getBean("employeeDao");
deptList=dao.getDeptsList();
//Employee employee=dao.getEmployeeforHRList(getLname(), getFname());
return SUCCESS;
}
这是我的数据访问文件中的代码:
public List<Department> getDeptsList(){
String query = "from Department";
List<Department> departments = getSession().createQuery(query).list();
return departments;
}
【问题讨论】:
-
我在执行方法中没有看到任何将获取的集合设置为表单 bean 的代码?
-
这是我的 struts.xml 文件中与此相关的部分:
-
对不起。 . .点击错误按钮:
我真的需要一个仅用于下拉列表的表单吗?没有输入的数据只显示从数据库中。human_res. jsp human_res.jsp human_res.jsp human_res.jsp -
你的jsp如何找到数据?
-
猜猜我发现了问题所在。 . .我必须为下拉菜单编写一个表单 bean :) 我的印象是我在 struts.xml 文件中的上述代码会做到这一点。感谢您的提醒!
标签: java hibernate jsp struts2