java - 如何使用带有 Stripes "option"标签的对象列表?

标签 java stripes

我有一个对象列表,由 JPA q.getResultList() 生成。

我想在下拉列表中使用它,但 Stripes“选项”标签不能接受列表,只能接受 CollectionEnum map

我是 Java 的新手,这就是为什么 List 可以翻译成它们中的每一个,但我不知道如何解决这个问题。

(Stripes select、option-map、-enumeration、-collection 可以从前面提到的输入对象结构中构建下拉列表)

最佳答案

的文档 options-collection 标签说:

Writes a set of <option value="foo">bar</option> tags to the page based on the contents of a Collection, Iterable or Array. Each element in the collection is represented by a single option tag on the page. Uses the label and value attributes on the tag to name the properties of the objects in the Collection that should be used to generate the body of the HTML option tag and the value attribute of the HTML option tag respectively. If either (or both) of the label or value properties are omitted the item itself will be used for the label/value instead - this is done to support collections of simple types like Strings and Numbers.

E.g. a tag declaration that looks like:

<stripes:options-collection collection="${cats}" value="catId" label="name"/>

would cause the container to look for a Collection called "cats" across the various JSP scopes and set it on the tag. The tag would then proceed to iterate through that collection calling getCatId() and getName() on each cat to produce HTML option tags.

A java.util.List 是一个 Collection ,只需将其传递给 collection提到的标签的属性。

关于java - 如何使用带有 Stripes "option"标签的对象列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2531072/

相关文章:

java - 如果基类匹配条件,IntelliJ 结构搜索将查找派生类

c# - Java 中 StringBuffer 的 .NET 等价物是什么?

java - 我的 EMR 集群在哪里

java - Stripes 框架中的对话范围

java - 单击android中的按钮时如何验证recyclerView项目

java - Vector vs Collections.synchronizedList(ArrayList)

java - 如何在 eclipse、tomcat 和 stripes 下将 .java 文件更改传播为 .class

java - 条纹框架死了吗?有人在用吗?

java - 如何将非字符串 Java 对象传递给 ActionBean - Stripes

java - 在 Stripes 中使用 MockRoundtrip 和 Guice