【问题标题】:Thymeleaf <select> tag generating options (numbers)Thymeleaf <select> 标签生成选项(数字)
【发布时间】:2014-10-14 03:37:51
【问题描述】:

我在 HTML 中有一个 &lt;select&gt; 标记,需要生成从 1 到 53 的选项,然后选择我要使用 doPost 方法发送的选项。

我尝试使用在这里找到的解决方案: http://forum.thymeleaf.org/generating-content-for-select-programatically-td4024742.html,

<select name="week_scroll"
      style="width: 70px; height: 27px">
   <option 
       th:each="n : ${#numbers.sequence(1,53)"
       th:text="${n}"
   />
</select>

但我得到一个错误:

org.thymeleaf.exceptions.TemplateProcessingException: 
Could not parse as each: "n : ${#numbers.sequence(1,53)" 

另外,生成后我应该使用哪个th: 标记从列表中进行选择?

【问题讨论】:

  • 您使用的是什么版本的百里香?我相信您需要 2.1.3 才能使这些实用程序类方法起作用。

标签: java html spring drop-down-menu thymeleaf


【解决方案1】:

th:each 属性的大括号 } 没有闭合

应该是

更新

<select name="week_scroll">
    <option>Select</option>
    <option th:each="n : ${#numbers.sequence(1,53)}" th:value="${n}" th:text="${n}"/>
</select>

【讨论】:

    猜你喜欢
    • 2018-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多