码迷,mamicode.com
首页 > Web开发 > 详细

3. HashMap和JSONObject用法

时间:2015-10-19 22:36:29      阅读:393      评论:0      收藏:0      [点我收藏+]

标签:

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

 

3. HashMap和JSONObject用法

标签:

原文地址:http://www.cnblogs.com/zkx4213/p/4893124.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!