Ajax 通过id 获取名字 以及 所属班级 获取数据得jsp

<%@ page contentType="text/html;charset=gb2312" %>

<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.yc.ycportal.blockimp.service.CommonService" %>

<%

response.setContentType("text/xml");  
         


  String userId = request.getParameter("userId");
  //Create the response XML
  if (userId != null && !"".equals(userId.trim())) {
   List gyList = CommonService.getInstance().getDynamicTable("select * from dic_counter where counter_id='" + userId + "'");
   
   if (gyList != null && gyList.size() == 1) {
    Map gyMap = (Map) gyList.get(0);
    String gyName = (String) gyMap.get("COUNTER_NAME");//柜员姓名
    String organId = (String) gyMap.get("ORGAN_ID");//柜员所属行号

    List organList = CommonService.getInstance().getDynamicTable("select * from dic_organ where organ_id='31" + organId + "'");
      if( organList != null && organList.size() == 1) {
       Map organMap = (Map) organList.get(0);
       String organName = (String) organMap.get("ORGAN_NAME");//获取柜员所属行名

       //组织需要返回的xml

       StringBuffer xml = new StringBuffer("success").append(gyName).append("").append(organId).append("").append(organName).append("");

       //Send the response back to the browser
       response.getWriter().write(xml.toString());
      }else{
        response.getWriter().write("failed");
       }
   }else{
     response.getWriter().write("failed");
    }
  }else{
     response.getWriter().write("failed");
  }

%> 

你可能感兴趣的:(Ajax)