json responseJson

private void doResoponseJson(HttpServletResponse resp,String jsonString){java

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

  

}json

相關文章
相關標籤/搜索