gpt4 book ai didi

java - 在 html 中迭代 TreeSet :option

转载 作者:行者123 更新时间:2023-12-01 14:31:15 28 4
gpt4 key购买 nike

有一种情况,我需要迭代 TreeSet 以便使用 html:option 填充下拉菜单,如下所示,

<html:select id="schoolLevel" name="schoolLevel">
<html:option value="">ALL</html:option>
<html:options property="schoolLevel" />
</html:select>

由于代码的当前设计,我需要将其作为 TreeSet 来执行,而不是将其更改为 map 列表。请问可以吗?

最佳答案

您可能正在寻找 optionsCollection tag :

Renders a set of HTML <option> elements, representing possible choices for a <select> element. This tag can be used multiple times within a single <html:select> element, either in conjunction with or instead of one or more or <html:options> elements.

This tag operates on a collection of beans, where each bean has a label property and a value property. The actual names of these properties can be configured using the label and value attributes of this tag.

关于java - 在 html 中迭代 TreeSet :option,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16853834/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com