首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在thyemeleaf中使用Select html标签?

如何在thyemeleaf中使用Select html标签?
EN

Stack Overflow用户
提问于 2017-09-30 20:54:10
回答 1查看 35关注 0票数 2

我将在我的theyemeleaf应用程序中添加一个select标记。代码如下:

<form th:action="@{/suggestevent}" th:object="${event}" method="post">
    <div class="form-group">
        <select class="form-control" name="type" th:field="*{type}">
            <option value="party" th:value="party">Party</option>
            <option value="Workshop" th:value="Workshop">Workshop</option>
            <option value="Friendship" th:value="Friendship">Friendship</option>
        </select>
    </div>
</form>

我的dropbox中只有三个固定值。问题是它没有在属性type中设置任何值。换句话说,它不起作用。

EN

回答 1

Stack Overflow用户

发布于 2017-10-03 18:03:27

当你使用胸腺叶和它们的属性时,比预期的要容易,然后只需要使用th:field和th:value,这两个属性默认情况下会添加属性名称和值,所以你不需要添加它。

<form th:action="@{/suggestevent}" th:object="${event}"  method="post">
    <div class="form-group">
        <select class="form-control" th:field="*{type}">
            <option th:value="party">Party</option>
            <option th:value="Workshop">Workshop</option>
            <option th:value="Friendship">Friendship</option>
        </select>
    </div>
</form>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46502901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档