gpt4 book ai didi

html - 如何使用 Spring MVC 制作带复选框的下拉列表?

转载 作者:行者123 更新时间:2023-11-27 23:53:28 25 4
gpt4 key购买 nike

我需要做类似的事情 http://i.stack.imgur.com/BHyyx.png ,但是我怎样才能用 spring 的标签做到这一点呢?我可以在 form:selectform:option 中输入一个复选框吗?

最佳答案

如果我们使用 JSTL 并创建它所需的 html ,我们就可以做到这一点。使用 bootstrap.jsbootstrap.css。我们可以从 Internet 下载它们并添加到我们的 spring 项目中。

示例在这里。

Checkbox dropdown

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

//import bootstrap js and css
<script src="../js/bootstrap/bootstrap.js" type="text/javascript"></script>
<link href="../themes/bootstrap/bootstrap.css" rel="stylesheet" type="text/css" />

//your form goes here

<form id="searchform" method="get" action="">
<div align="center">
<div class="input-group">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Select
Designation :</button>
<button tabindex="-1" data-toggle="dropdown"
class="btn btn-default dropdown-toggle" type="button">
<span class="caret"></span>
</button>
<ul role="menu" class="dropdown-menu" style="vertical-align: top;">
<li style="vertical-align: top;"> <input id="all" name="all" type="checkbox" style="width:30px;height:auto;cursor: pointer;"><label
style="vertical-align: middle;width:100%;cursor: pointer;;" for="all" > All</label>
</li>
<li class="divider"></li>
<c:forEach items="${designationList}" var="d" varStatus="status">

<li style="vertical-align: top;"><input id="${d.id}" name="${d.id}" type="checkbox" style="width:30px;height:auto;cursor: pointer;"> <label
for="${d.id}" class="lbl" style="color: #489D1F;vertical-align: middle;width:100%;cursor: pointer;"> ${d.designation}</label>
</li>
</c:forEach>
</ul>
</div>

</div>
</form>

免责声明: 我不知道使用 Spring 标签是否可以实现同样的效果,但我只知道这种方式,所以我与您分享了它。可能有人知道并会发布更好的答案。但在我们找到适合 Spring 标签的正确方法之前,这种方法可能会对您有所帮助。

关于html - 如何使用 Spring MVC 制作带复选框的下拉列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25485386/

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