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

	//仓库业务类型 第一种
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. Jquery | 基础 | 属性过滤选择器

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 洛谷 P2759 奇怪的函数

    https://www.luogu.org/problemnew/show/P2759 #include<cstdio> #include<algorithm> #includ ...

  3. 线段树(单点更新) POJ 2886 Who Gets the Most Candies?

    题目传送门 #include <cstdio> #include <cstring> #define lson l, m, rt << 1 #define rson ...

  4. 数字(number)

    数字(number) Time Limit:2000ms   Memory Limit:128MB 题目描述 LYK定义了一个新的计算. 具体地,一开始它有两个数字a和b. 每一步,它可以将b增加1, ...

  5. git找不到远程库问题

    git报错:Couldn't find remote ref XXXX (gitlab报错)XXXX does not appear to be a git repository Could not ...

  6. Spring数据访问1 - 数据源配置及数据库连接池的概念

    无论你要选择哪种数据访问方式,首先你都需要配置好数据源引用. Spring中配置数据源的几种方式 通过在JDBC驱动程序定义的数据源: 通过JNDI查找的数据源: 连接池的数据源: 对于即将发布到生产 ...

  7. ES6学习笔记(11)----Proxy

    参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ Proxy1.概述    Proxy可以用来修改对象的默认操作    let obj = {na ...

  8. JAVA设计模式--Strategy

    策略模式就是说当我进行比较大小的时候定义一个策略的比较器Comparator,然后由具体的比较策略来决定用什么量来比较大小.

  9. C#创建任务计划

    因写的调用DiskPart程序是要用管理员身份运行的,这样每次开机检查都弹个框出来确认肯定不行.搜了下,似乎也只是使用任务计划程序运行来绕过UAC提升权限比较靠谱,网上的都是添加到计算机启动的,不是指 ...

  10. Devops 技术图谱