private void doResoponseJson(HttpServletResponse resp,String jsonString){
Trace.logError(Trace.COMPONENT_ACTION,"返回结果:"+jsonString); OutputStream eos =null; InputStream eTargetIS=null; try{ resp.setContentType("text/json"); resp.setCharacterEncoding("UTF-8"); resp.setHeader("Cache-Control", "no-cache"); resp.setHeader("Pragma", "no-cache"); resp.setHeader("Expires", "date"); eos = resp.getOutputStream(); eTargetIS = new ByteArrayInputStream(jsonString.getBytes("UTF-8")); int r; while ((r = eTargetIS.read()) != -1) { eos.write(r); } eTargetIS.close(); eos.flush(); eos.close(); } catch (Exception e1) { Trace.logError(Trace.COMPONENT_ACTION,"Ajax返回信息时出现异常:",e1); } finally{ try{ if(eos!=null){ eos.close(); } } catch(Exception e){ Trace.logError(Trace.COMPONENT_ACTION,"Ajax返回信息后关闭OutputStream出现异常:",e); } try{ if(eTargetIS!=null){ eTargetIS.close(); } } catch(Exception e){ Trace.logError(Trace.COMPONENT_ACTION,"Ajax返回信息后关闭InputStream出现异常:",e); } }
}