form:checkboxes radiobutton select用法

        <form:checkboxes path="subjects" items="${requestScope.subjects}"  element="label class='checkbox-inline'" itemLabel="name" itemValue="id"/><br/>

生成的代码

<label class="checkbox-inline"><input id="subjects1" name="subjects" type="checkbox" value="8"><label for="subjects1">测试</label></label>
<form:radiobuttons path="receive.accType.id"
                        element="label class='radio' <span style="color:#3366FF;">style='margin-right:4px;'</span>"
                            items="${accTypes }" itemLabel="name" itemValue="id"/>
<form:checkboxes element="label class='checkbox' <span style="color:#3333FF;">style='margin-right:10px;'</span>"
                            items="${accNature }" path="accNature" 
                            itemLabel="name" itemValue="id"/>
<form:radiobutton path="arriveway" value="1" checked="true"/>安吉汽车站&emsp;

 

<form:radiobuttons path="leaderId"
                    items="${requestScope.subject.users }"  element="label class='radio'" itemLabel="name"
                    itemValue="id" />

 

 

参考:

Spring MVC框架checkboxes标签的三种使用方式

Spring form 学习之(一)--radiobuttons & checkboxes样式

select

<form:select  class="form-control" path="subject.id" items="${requestScope.subjects}" itemLabel="name"
                    itemValue="id"></form:select>
生诚的html代码
<select id="subject.id" name="subject.id" class="form-control"><option value="1" selected="selected">英语</option><option value="2">数学</option><option value="3">语文</option></select>

后台取数据
@RequestParam(value="subject.id", required=false) Integer subjectId

 

protected Map referenceData(HttpServletRequest request) throws Exception {
    Map referenceData = new HashMap();
    Map<String,String> country = new LinkedHashMap<String,String>();
    country.put("US", "United Stated");
    country.put("CHINA", "China");
    country.put("SG", "Singapore");
    country.put("MY", "Malaysia");
    referenceData.put("countryList", country);
}
<form:select path="country" items="${countryList}" />
<form:select path="country">
    <form:options items="${countryList}" />
</form:select>

2. <form:options />

The <form:options /> have to enclosed with the select tag.

<form:select path="country"> <form:options items="${countryList}" /> </form:select> 
Copy

HTML code

<select id="country" name="country"> <option value="US">United Stated</option> <option value="CHINA">China</option> <option value="SG">Singapore</option> <option value="MY">Malaysia</option> </select> 
Copy

3. <form:option />

The <form:option /> have to enclosed with the select tag as well, and render a single select option, see the following combination.

<form:select path="country"> <form:option value="NONE" label="--- Select ---"/> <form:options items="${countryList}" /> </form:select> 
Copy

HTML code

<select id="country" name="country"> <option value="NONE">--- Select ---</option> <option value="US">United Stated</option> <option value="CHINA">China</option> <option value="SG">Singapore</option> <option value="MY">Malaysia</option> </select> 
Copy

4. List box

To render a list box, just add the “multiple=true” attribute in the select tag.

<form:select path="country" items="${countryList}" multiple="true" /> 
Copy

HTML code, with a hidden value to handle the country selections.

<select id="country" name="country" multiple="multiple"> <option value="US">United Stated</option> <option value="CHINA">China</option> <option value="SG">Singapore</option> <option value="MY">Malaysia</option> </select> <input type="hidden" name="_country" value="1"/> 

 

转载于:https://www.cnblogs.com/znsongshu/p/10135111.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值