zoukankan      html  css  js  c++  java
  • 3. HashMap和JSONObject用法

    <%@page import="net.sf.json.JSONObject"%>
    <%@page import="java.util.List"%>
    <%@page import="java.util.ArrayList"%>
    <%@page import="java.util.HashMap"%>

    String sql = "select b.CardCode,b.cardname from Wbtx_Tkhjbxx b where b.id in (select distinct a.wbtx_tkhjbxx_id from wbtx_Tkhjbxx_YWYXX a where a.xsy = "+UserContext.getContext().getUser().getId()+")";
    String cusCode = "";
    String cardname="";
    List list=new ArrayList();
    List list1=new ArrayList();
    ApexRowSet rs_1 = null;
    rs_1 = ApexDao.getRowSet(DataAccess.getDataSource(), sql);
    while(rs_1.next()){
      HashMap<String, Object> sh=new HashMap<String, Object>();
      JSONObject node = new JSONObject();
      cusCode = rs_1.getString("CardCode");
      cardname = rs_1.getString("cardname");
      sh.put("cusCode",cusCode);
      sh.put("cardname",cardname);
      node.put("cusCode",cusCode);
      node.put("cardname",cardname);
      list.add(sh);
      list1.add(node);
    }
    request.setAttribute("list",list);
    request.setAttribute("list1",list1);

    <%
    for(int i=0;i<list.size();i++){
      HashMap hm=(HashMap)list.get(i);
    %>
      <option value="<%=hm.get("cusCode") %>"><%=hm.get("cardname") %></option>
    <%
    }
    %>

    //js中

    var contactorList = <%=request.getAttribute("contactorList")%>;

    for(var i in contactorList) {
      var khdm=contactorList[i].khdm;
      var contactor=contactorList[i].contactor;
      if(khdm == v_cusCode) {
        var option = document.createElement("option");
        option.innerHTML=contactor;
        option.value=khdm;
        select2.appendChild(option);
      }
    }

  • 相关阅读:
    python dict
    用Python requests beautifulSoup 获取并显示中文信息
    Python information to learn
    Python 中的异常
    Python 中的函数
    安装Linux系统Fedora 23
    (转)开源协议的比较
    WizNote for linux installation
    linux下编译bib、tex生成pdf文件
    NLP学术组织、会与论文
  • 原文地址:https://www.cnblogs.com/zkx4213/p/4893124.html
Copyright © 2011-2022 走看看