在我使用数据表创建的 primefaces 3.5 表单上,rowKey 值未作为列表返回,因此我收到以下错误:
JBWEB000309: type JBWEB000066: Exception report
JBWEB000068: message For input string: "foreignPartyId"
JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.
JBWEB000070: exception
javax.servlet.ServletException: For input string: "foreignPartyId"
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
JBWEB000071: root cause
java.lang.NumberFormatException: For input string: "foreignPartyId"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:492)
java.lang.Integer.parseInt(Integer.java:527)
javax.el.ListELResolver.toInteger(ListELResolver.java:407)
javax.el.ListELResolver.getValue(ListELResolver.java:199)
...
我知道原因是因为我试图用 Object[] 数组而不是列表中的值填充数据表。 Object[] 数组实际上是使用 createNativeQuery 方法查询 Oracle 数据库的 getResultList() 中的值。
我的问题是:如何将 Object[] 数组中的值转换为列表以便填充数据表?
我尝试使用 Arrays.toList() 方法,然后迭代该方法将值添加到列表中,但我知道这只是返回支持数组的固定大小列表。它不返回值列表。
任何帮助将不胜感激。如果我没有提供足够的细节,我深表歉意。谢谢。
最佳答案
尝试使用ArrayList:
ArrayList<Object> list = new ArrayList(Arrays.asList(yourArray));
然后使用将您想要的任何元素添加到列表中
list.add(newItem)
关于java - 在java中将Object[]数组转换为List,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28973317/