Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用html的整数数组下拉列表:选择_Java_Jsp_Struts - Fatal编程技术网

Java 使用html的整数数组下拉列表:选择

Java 使用html的整数数组下拉列表:选择,java,jsp,struts,Java,Jsp,Struts,我一直在开发stuts应用程序,其中我使用的是整数数组列表。我需要创建一个下拉列表来列出arraylist 我一直在尝试使用html:select-->html:optioncollection 但我得到的错误是无法为com创建迭代器。SelectTagForm@18488ef 代码: 提前感谢 这是引发异常的代码片段。它来自选项集合标签 protected Iterator getIterator(Object collection) throws JspException { i

我一直在开发stuts应用程序,其中我使用的是整数数组列表。我需要创建一个下拉列表来列出arraylist

我一直在尝试使用html:select-->html:optioncollection

但我得到的错误是
无法为com创建迭代器。SelectTagForm@18488ef

代码:



提前感谢

这是引发异常的代码片段。它来自
选项集合
标签

protected Iterator getIterator(Object collection)
  throws JspException {
  if (collection.getClass().isArray()) {
    collection = Arrays.asList((Object[]) collection);
  }
  if (collection instanceof Collection) {
    return (((Collection) collection).iterator());
  } else if (collection instanceof Iterator) {
    return ((Iterator) collection);
  } else if (collection instanceof Map) {
    return (((Map) collection).entrySet().iterator());
  } else if (collection instanceof Enumeration) {
    return new IteratorAdapter((Enumeration) collection);
  } else {
    throw new JspException(messages.getMessage(
        "optionsCollectionTag.iterator", collection.toString()));
  }
}
不知道您的完整设置是什么,因为您只发布了一行代码,但很明显,您没有将正确的集合发送给它(您发送的是错误消息指定的
com.SelectTagForm

仔细阅读;这是一个简单的教程

另一方面,该标记在bean集合上运行,其中每个bean都有一个label属性和一个value属性(这些属性的实际名称可以使用该标记的
label
value
属性进行配置)。您不能从Integer ArrayList中提取类似的内容(正如您指定的那样)

protected Iterator getIterator(Object collection)
  throws JspException {
  if (collection.getClass().isArray()) {
    collection = Arrays.asList((Object[]) collection);
  }
  if (collection instanceof Collection) {
    return (((Collection) collection).iterator());
  } else if (collection instanceof Iterator) {
    return ((Iterator) collection);
  } else if (collection instanceof Map) {
    return (((Map) collection).entrySet().iterator());
  } else if (collection instanceof Enumeration) {
    return new IteratorAdapter((Enumeration) collection);
  } else {
    throw new JspException(messages.getMessage(
        "optionsCollectionTag.iterator", collection.toString()));
  }
}