如何将数据放入下拉框List值
最近在做下拉框,里面放入值大概有这几种
//仓库业务类型 第一种
model.addAttribute("warehouseBizTypeList", basePropertyService.loadPropertyDicByPropertyId(PropertyDictionary.WAREHOUSE_BIZ_TYPE));
//所属客户:分部 第二种
model.addAttribute("customerBelongedList",customerInfoService.loadBelongedCustomer());
第一种是放入数据字典
/**
* 仓库业务类型
*/
Long WAREHOUSE_BIZ_TYPE=Long.valueOf(36204456);
这样warehouseBizTypeList就拥有主键值为36204456所对应的
select * from base_property_dictionary where property_id=36887947
+---------------+-------------+----------------+--------+---------------+
| dictionary_id | property_id | property_value | status | property_code |
+---------------+-------------+----------------+--------+---------------+
| 36886416 | 36204456 | 实体仓 | A | 1 |
| 36886417 | 36204456 | 虚拟实体仓库 | A | 2 |
| 36886418 | 36204456 | 虚拟仓 | A | 3 |
| 36886419 | 36204456 | 逻辑仓 | A | 4 |
+---------------+-------------+----------------+--------+---------------+
在JSP页面
<td style="vertical-align:middle" align="right" width="10%"><label><span class="redmark">*</span> 仓库业务类型:</label></td>
<td style="vertical-align:middle" align="left" width="20%">
<select name="warehouseType" id="warehouseType" style="width:95%">
<option value="">--请选择--</option>
<c:forEach var="bizTypeList" items="${warehouseBizTypeList}" varStatus="s">
<option value="${bizTypeList.propertyCode}" <c:if test="${bizTypeList.propertyCode eq warehouseInfo.warehouseType}">selected="selected"</c:if>>${bizTypeList.propertyValue}</option>
</c:forEach>
</select>
</td>
第二种,不用数据字典,通过hibernate find筛选出 List
@SuppressWarnings("unchecked")
public List<CustomerInfo> loadBelongedCustomer() {
String resultSql = "from CustomerInfo t where t.status='A' and t.bussinessType='6' order by t.isRenter asc";
//查询租户不需要权限过滤。加如下语句。
//ThreadLocalClient.get().envParamMap.put(DataAuthority.IS_APPLY_AUTHORITY, false);
List<CustomerInfo> list = hibernateTemplate.find(resultSql);
//ThreadLocalClient.get().envParamMap.put(DataAuthority.IS_APPLY_AUTHORITY, null);
return list;
}
对于JSP
<td style="vertical-align:middle" align="right" width="10%"><label><span class="redmark">*</span>所属客户:</label></td>
<td style="vertical-align:middle" align="left" width="20%">
<select name="baseBusinessOrg" style="width:95%">
<option value="">--请选择--</option>
<c:forEach var="customerBelonged" items="${customerBelongedList}">
<option value="${customerBelonged.id}"
<c:if test="${warehouseInfo.customerBelonged.id==customerBelonged.id}"> selected</c:if>><c:out value="${customerBelonged.customerName}"/></option>
</c:forEach>
</select>
</td>
如何将数据放入下拉框List值的更多相关文章
- easyui的combobox将得到的数据设定为下拉框默认值和复选框设定默认值
通过easyui做了一个表,表里是从数据库拿到的数据. 现在双击某一行,通过点击行的id取到这一行的所有数据,现在需要修改这些得到的数据, 其中部分数据是<select>这个选择的, 问题 ...
- jquery学习笔记:获取下拉框的值和下拉框的txt
<div class="form-group"> <select class="form-control" id="iv_level ...
- js&jquery 获取select下拉框的值、文本内容、自定义属性
js&jquery 获取select下拉框的值.文本内容.自定义属性 CreationTime--2018年7月2日09点22分 Author:Marydon html <selec ...
- layui 根据根据后台数据动态创建下拉框并同时默认选中
第一步 form表单里写好一个下拉框 <div class="layui-form-item"> <label class="layui-for ...
- web项目页面加载时,下拉框有值
1.我用的框架是springmvc和mybaitis 由于没有整个项目,直接就去请求的action :http://localhost:8080/ytert/test/selectStoreType ...
- Jquery学习笔记:利用jquery获取select下拉框的值
jquery不是特别熟练,每次使用不常用的就要百度,特地记录下来. 我的下拉框是: <div class="form-group"> <select class= ...
- selenium如何随机选取省份和城市的下拉框的值
1.原始需求,选择省份后,相应的城市会自动加载 2.思路 a.获取下拉框的所有元素个数 b.随机点击0-元素个数之间的某个值 3.代码实现 Random random = new Random(); ...
- select获取下拉框的值 下拉框默认选中
本文主要介绍select下拉框的相关方法. 1.通过id获取下拉框的value和文本值 例如: <select class="form-control" id=" ...
- MVC 下拉框获取值和赋值(多选)
1.视图 <div class="form-group"> @Html.LabelFor(m => m.Positions, new { @class = &qu ...
随机推荐
- Java | 基础归纳 | java时间格式处理总结
https://www.cnblogs.com/edwardlauxh/archive/2010/03/21/1918615.html https://blog.csdn.net/xsj_blog/a ...
- flask跨域问题
在Flask开发RESTful后端时,前端请求会遇到跨域的问题.下面是解决方法: 使用 flask-cors库可以很容易的解决 1 pip install flask-cors 两种方法,一个是全 ...
- _bzoj1257 [CQOI2007]余数之和sum【小技巧】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1257 最近刚做了一道莫比乌斯的题,需要用到这种方法. 应该让k / i相等的一连串k % i ...
- 金蝶Apusic中间件适配JetSpeed2过程记录
金蝶Apusic中间件适配JetSpeed2过程记录: 1.安装金蝶并配置域,确保域运行正常. 2.参考<JetSpeed2部署至Apusic操作步骤记录>进行应用迁移. https:// ...
- h5-16-SVG 与 HTML5 的 canvas 各自特点
1. Canvas是使用JavaScript程序绘图(动态生成),SVG是使用XML文档描述来绘图.2.SVG更适合用来做动态交互,而且SVG绘图很容易编辑,只需要增加或移除相应的元素就可以了.同时S ...
- C++类成员函数与成员变量的内存布局
一.成员函数 成员函数可以被看作是类作用域的全局函数,不在对象分配的空间里,只有虚函数才会在类对象里有一个指针,存放虚函数的地址等相关信息.
- Problem E: 穷游中国在统题 优先队列 + 模拟
http://www.gdutcode.sinaapp.com/problem.php?cid=1049&pid=4 Problem E: 穷游中国在统题 Description Travel ...
- 摄像头调用,h5调用摄像头进行扫一扫插件备份
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- Springboot + Websocket + Sockjs + Stomp + Vue + Iview 实现java后端日志显示在前端web页面上
话不多说,看代码. 一.pom.xml 引入spring boot websocket依赖 <dependency> <groupId>org.springframework. ...
- 【学习笔记】C++ cout 输出小数点后指定位数
在C中我们可以使用 printf("%.2lf",a);但在C++中是没有格式操作符的,该如何操作: C++使用setprecision()函数,同时必须包含头文件iomanip, ...