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

	//仓库业务类型 第一种
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. only-child选择器

    :only-child选择器用于匹配属于某一个父元素的唯一子元素的元素,也就是说,如果某个父元素仅有一个子元素,则使用  :only-chlid选择器  ,可以选择这个子元素

  2. document.body 与 document.documentElement区别介绍

    什么是document.body? 返回html dom中的body节点 即<body> 什么是 document.documentElement? 返回html dom中的root 节点 ...

  3. codeforces 629C Famil Door and Brackets (dp + 枚举)

    题目链接: codeforces 629C Famil Door and Brackets 题目描述: 给出完整的括号序列长度n,现在给出一个序列s长度为m.枚举串p,q,使得p+s+q是合法的括号串 ...

  4. E. Anton and Tree 数组开大点

    http://codeforces.com/contest/734/problem/E 看了题解,缩点 + 树的直径. 然而一直wa14. 注意到, 缩点后重建图,在5的时候,5和6建了一条边,然后6 ...

  5. webfrom ASP开发基础跟模式

    ASP.NET - .net开发网站应用程序的技术总称 ASP WebForm           MVC   是ASP.NET的两个技术方法 WebForm类似于WinForm,可视化操作 MVC类 ...

  6. #pragma使用分析

    #pragma简介 #pragma用于指示编译器完成一些特定的动作 #pragma所定义的很多指示字是编译器特有的 #pragma在不同的编译器间是不可移植的 预处理器将忽略它不认识的#pragma指 ...

  7. ceph集群一键部署脚本

    分布式存储ceph相信大家比较熟悉了.某项目临时要做一个40个节点的存储集群.所以写了这个脚本. 一键部署脚本如下: git clone https://github.com/luckman666/d ...

  8. php中include_path配置

    在php.ini中可配置include_path来达到在任何文件中都可以直接引入该目录下文件 include_path = ".:/usr/share/php:/var/www/phpxwl ...

  9. get log

    C:\Users\wb_changxiang.chen\Desktop\get_log_adb.py #! /usr/bin/env pythonimport osimport sysimport t ...

  10. vue 组件内 directives指令的调用方式 <base-table v-auto-height:tableHeight="{vm:this, diffHeight:ahTable.diffHeight}"

    vue 组件内 directives指令的调用方式 <base-table v-auto-height:tableHeight="{vm:this, diffHeight:ahTabl ...