@RequestMapping(value = "/AjaxQuery.html") public String AjaxQuery( @RequestParam(value = "entryValue") String entryValue, HttpServletRequest request, HttpServletResponse response) { List<FiForeigner> foreignlist = null; String value = Untils.NotNull(entryValue) ? entryValue : ""; if (Untils.NotNull(value)) { foreignServices = (ForeignServices) springContextUtil.getBean("ForeignServices"); foreignlist = foreignServices.QueryByName("%" + value + "%"); } List list = new ArrayList(); if (foreignlist != null && foreignlist.size() > 0) { for (FiForeigner forei : foreignlist) { JSONObject object = new JSONObject(); // System.out.println(forei.getName()+" , "+forei.getPassportId()); if (Untils.NotNull(value)) { object.put("name", forei.getName()); object.put("pp_id", forei.getPassportId()); object.put("id", forei.getId()); } list.add(object); } } response.setContentType("text/Xml;charset=utf-8"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("pragma", "no-cache"); response.setDateHeader("expires", 0); PrintWriter out = null; try { out = response.getWriter(); out.println(list); } catch (IOException ex1) { ex1.printStackTrace(); } finally { out.close(); } return null; }