无法弄清楚如何< s:select>

编程入门 行业动态 更新时间:2024-10-25 15:29:27
本文介绍了无法弄清楚如何< s:select>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 试图获得中的公司名单,选择但它给我一个错误。

类型异常报告 消息标记'select',字段'list',名称'workOrder。公司':请求的列表键'listAllCompanys'不能被解析为一个集合/数组/映射/枚举/迭代器类型。示例:人员或人员{名称} - [未知位置] 描述服务器遇到内部错误,无法完成此请求。

例外情况:

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.

更多推荐

无法弄清楚如何&lt; s:select&gt;

本文发布于:2023-11-27 02:56:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636279.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弄清楚   amp   lt   select   gt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!