例外情况:
org.apache.jasper.JasperException:标记'select',字段'list',名称'workOrderpany':请求的列表键'listAllCompanys'无法解析为集合/数组/映射/枚举/迭代器类型。示例:人员或人员。{名称} - [未知位置] org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:585) org.apache.jasper.servlet.JspServletWrapper。服务(JspServletWrapper.java:470)我的 workOrder.jsp 包含以下内容的文件:
< s:select list =listAllCompanyslistValue =companyNamename =workOrder 。公司>< /秒:选择>当我有新的工作订单要添加时,应该有select中可用的公司列表。
更新:
以下是我的 listAllCompanies()方法
public List< Company> getCompanyList(){ return companyList; } ///////////////////////////////////// ///// ///////////////////////////////////////// 公开清单<公司> getListAllCompanys(){ return listAllCompanys; } 私人列表<公司> listAllCompanys; public String listAllCompanys()抛出异常 { CompanyDaoHibernate dao = new CompanyDaoHibernate(); listAllCompanys = dao.getListOfCompanys(); 返回SUCCESS;CompanyDAOHibernate :
public List< Company> getListOfCompanys() { SessionFactory sf = HibernateUtil.getSessionFactory(); 会话会话= sf.openSession(); @SuppressWarnings(unchecked) List< Company> returnList =(List< Company>)session.createCriteria(Company.class).list(); session.close(); System.out.println(Printing companies ...+ returnList); 返回returnList; $解析方案JSP包含操作返回的选择标记。当你添加一个订单时,它应该有一个绑定到bean属性的 list 属性。它应该是值堆栈中的顶部对象。
在大多数情况下,初始化action类中的属性可以更好地实现 可预备 您必须在其中编写 prepare()方法并初始化列表。
抛出异常是因为 s的列表属性:select 标记不能是 null 。您应该在返回引用该变量的结果之前正确初始化用于标记的变量。
Trying to get list of companies in select but it gives me an error.
type Exception report message tag 'select', field 'list', name 'workOrderpany': 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.Exception:
org.apache.jasper.JasperException: tag 'select', field 'list', name 'workOrderpany': 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)my workOrder.jsp file containing :
<s:select list="listAllCompanys" listValue="companyName" name="workOrderpany"></s:select>When I have a new work order to add, there should be a list of companies available in select .
UPDATE:
Here's my listAllCompanies() method
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:
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; }解决方案
The JSP contains a select tag returned by the action. When you add an order it should have a list attribute bound to the bean property. It should be a top object in the value stack.
In most cases initializing that property in the action class better to implement Preparable where you have to write prepare() method and initialize the list.
The exception is thrown because the list attribute of the s:select tag couldn't be null. You should properly initialize the variable used for the tag before returning a result that has references to that variable.
更多推荐
无法弄清楚如何< s:select>
发布评论