试图获得公司名单,select但这给了我一个错误。
select
type Exception report message tag 'select', field 'list', name 'workOrder.company': The requested list key 'listAllCompanys' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] description The server encountered an internal error that prevented it from fulfilling this request.
例外:
org.apache.jasper.JasperException: tag 'select', field 'list', name 'workOrder.company': The requested list key 'listAllCompanys' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:585) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
我的workOrder.jsp文件包含:
workOrder.jsp
<s:select list="listAllCompanys" listValue="companyName" name="workOrder.company"></s:select>
当我要添加新的工作订单时,select中应该有可用的公司列表。
更新:
这是我的listAllCompanies()方法
listAllCompanies()
public List<Company> getCompanyList() { return companyList; } ////////////////////////////////////////// ///////////////////////////////////////// public List<Company> getListAllCompanys() { return listAllCompanys; } private List<Company> listAllCompanys; public String listAllCompanys() throws Exception { CompanyDaoHibernate dao = new CompanyDaoHibernate(); listAllCompanys = dao.getListOfCompanys(); return SUCCESS; }
CompanyDAOHibernate:
CompanyDAOHibernate
public List<Company> getListOfCompanys() { SessionFactory sf = HibernateUtil.getSessionFactory(); Session session = sf.openSession(); @SuppressWarnings("unchecked") List<Company> returnList = (List<Company>)session.createCriteria(Company.class).list(); session.close(); System.out.println("Printing companies... "+returnList); return returnList; }
JSP包含操作返回的选择标记。添加订单时,它应该具有list绑定到bean属性的属性。它应该是top值堆栈中的一个对象。
list
top
在大多数情况下,最好在操作类中初始化该属性,以更好地实现Preparable必须编写prepare()方法和初始化列表的位置。
Preparable
prepare()
因为标签的list属性s:select不能为引发异常null。在返回引用该变量的结果之前,应正确初始化用于标签的变量。
s:select
null