Reputation: 1610
I keep getting the following struts error:
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
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]
. . .
Here is the code in my .jsp file:
<s:select name="dept" list="deptList" listKey="deptId" listValue="deptString" headerKey="0" headerValue="Select a Department"
label="Select Department" />
Here is the code in my action file (which I have by debugging verifyed that it returns the correct values):
@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;
}
Here is the code in my data access file:
public List<Department> getDeptsList(){
String query = "from Department";
List<Department> departments = getSession().createQuery(query).list();
return departments;
}
Upvotes: 0
Views: 922
Reputation: 240870
You need to set the list into formBean
You are looking up from jsp for collection and you don't have set that collection in the FormBean that or you can also set it in request/page/session/application scope with proper EL.
Upvotes: 4