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

  • 相关阅读:
    web.xml中load-on-startup的作用
    Spring加载resource时classpath*:与classpath:的区别
    免费svn远程仓库推荐
    学习websocket
    eclipse下的maven
    maven常用命令
    文件操作的补充
    模块
    正则表达式,计算器,装饰器,冒泡排序,用户登录系统
    拷贝,集合,函数,enumerate,内置函数
  • 原文地址:https://www.cnblogs.com/zkx4213/p/4893124.html
Copyright © 2020-2023  润新知