zoukankan      html  css  js  c++  java
  • 如何将数据放入下拉框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="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="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>
    
  • 相关阅读:
    学习进度条
    学习进度条
    《软件需求模式》读书笔记04
    大型网站技术架构阅读笔记5
    大型网站技术架构阅读笔记4
    大型网站技术架构阅读笔记3
    大型网站技术架构阅读笔记2
    大型网站技术架构阅读笔记1
    《uml大战需求分析》阅读笔记06
    《uml大战需求分析》阅读笔记05
  • 原文地址:https://www.cnblogs.com/kyxyes/p/3572891.html
Copyright © 2011-2022 走看看