最近在做下拉框,里面放入值大概有这几种

	//仓库业务类型 第一种
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值的更多相关文章

  1. easyui的combobox将得到的数据设定为下拉框默认值和复选框设定默认值

    通过easyui做了一个表,表里是从数据库拿到的数据. 现在双击某一行,通过点击行的id取到这一行的所有数据,现在需要修改这些得到的数据, 其中部分数据是<select>这个选择的, 问题 ...

  2. jquery学习笔记:获取下拉框的值和下拉框的txt

    <div class="form-group"> <select class="form-control" id="iv_level ...

  3. js&jquery 获取select下拉框的值、文本内容、自定义属性

      js&jquery 获取select下拉框的值.文本内容.自定义属性 CreationTime--2018年7月2日09点22分 Author:Marydon html <selec ...

  4. layui 根据根据后台数据动态创建下拉框并同时默认选中

        第一步 form表单里写好一个下拉框 <div class="layui-form-item"> <label class="layui-for ...

  5. web项目页面加载时,下拉框有值

    1.我用的框架是springmvc和mybaitis 由于没有整个项目,直接就去请求的action  :http://localhost:8080/ytert/test/selectStoreType ...

  6. Jquery学习笔记:利用jquery获取select下拉框的值

    jquery不是特别熟练,每次使用不常用的就要百度,特地记录下来. 我的下拉框是: <div class="form-group"> <select class= ...

  7. selenium如何随机选取省份和城市的下拉框的值

    1.原始需求,选择省份后,相应的城市会自动加载 2.思路 a.获取下拉框的所有元素个数 b.随机点击0-元素个数之间的某个值 3.代码实现 Random random = new Random(); ...

  8. select获取下拉框的值 下拉框默认选中

    本文主要介绍select下拉框的相关方法. 1.通过id获取下拉框的value和文本值 例如:  <select class="form-control" id=" ...

  9. MVC 下拉框获取值和赋值(多选)

    1.视图 <div class="form-group"> @Html.LabelFor(m => m.Positions, new { @class = &qu ...

随机推荐

  1. the little schemer 笔记(6)

    第六章 Shadows 1 是算术表达式吗 是 3 是算术表达式吗 是的 1+3 是算术表达式吗 是的 1+3×4 是算术表达式吗 当然是 cookie 是算术表达式吗 是啊,你需要来一块吗 e那么 ...

  2. python之unittest

    unittest是单元测试的一个框架 在说unittest之前,先说几个概念: TestCase 也就是测试用例 TestSuite 多个测试用例集合在一起,就是TestSuite TestLoade ...

  3. UVA - 11082 Matrix Decompressing

    2. B - Matrix Decompressing 题意:定义一个R*C的正整数矩阵(1<=R,C<=20),设Ai为前i行所有元素之和,Bi为前i列所有元素之和. 题目已知R,C和数 ...

  4. Odd sum CodeForces - 797B

    Odd sum CodeForces - 797B 好方法:贪心 贪心2 糟糕(不用动脑)的方法:dp ans[i][0]表示到第i个和为偶数最大,ans[i][1]表示到第i个和为奇数最大. 但是, ...

  5. Linux常用命令——tac、bc

    1.从文件尾到文件头一页一页的显示内容 tac xxx.log |more //tac命令与cat命令相反,从文件尾开始读文件 2.shell下科学计算工具bc echo "scale=5; ...

  6. P2629 好消息,坏消息

    题目描述 uim在公司里面当秘书,现在有n条消息要告知老板.每条消息有一个好坏度,这会影响老板的心情.告知完一条消息后,老板的心情等于之前老板的心情加上这条消息的好坏度.最开始老板的心情是0,一旦老板 ...

  7. js 判断客户端系统

    function detectOS() { var sUserAgent = navigator.userAgent; var isWin = (navigator.platform == " ...

  8. JS学习-事件响应小结-简单的计算器

    <!DOCTYPE html> <html> <head> <title> 事件</title> <script type=" ...

  9. 【HEVC帧间预测论文】P1.2 An Efficient Inter Mode Decision Approach for H.264 Video Codin

    参考:An Efficient Inter Mode Decision Approach for H.264 Video Coding <HEVC标准介绍.HEVC帧间预测论文笔记>系列博 ...

  10. COGS 1406. 邻居年龄排序[Age Sort,UVa 11462](水题日常)

    ★   输入文件:AgeSort.in   输出文件:AgeSort.out   简单对比时间限制:1 s   内存限制:2 MB [题目描述] Mr.Zero(CH)喜闻乐见地得到了一台内存大大增强 ...