• 如何将数据放入下拉框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>
    
  • 相关阅读:
    《网络攻防》实验八:Web基础
    《网络攻防》实验七:网络欺诈技术防范
    《网络攻防》实验六:信息搜集与漏洞扫描
    《网络攻防》实验五:MSF基础应用
    《网络攻防》实验四:恶意代码分析
    《网络攻防》实验三:免杀原理与实践
    《网络攻防》实验二:后门原理与实践
    20145213《网络对抗》逆向及Bof基础
    《课程设计》——cupp的使用
    《课程设计》——foremost的使用
  • 原文地址:https://www.cnblogs.com/kyxyes/p/3572891.html
Copyright © 2020-2023  润新知