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);
      }
    }

  • 相关阅读:
    Linux OS共享文件
    源代码安装软件-MySQL
    细说Linux权限
    Linux进程作业的查看和杀死
    Linux_破解密码-营救模式
    找不同diff-打补丁patch
    WINDOWS自带md5校验工具
    猪,兔,等动物解剖平面图
    利用mimikatz破解远程终端凭据,获取服务器密码
    PHP中通过bypass disable functions执行系统命令的几种方式
  • 原文地址:https://www.cnblogs.com/zkx4213/p/4893124.html
Copyright © 2011-2022 走看看