ajax后台处理响应(java)

public static final void sendAsJson(HttpServletResponse response, String str)  
{  
  response.setContentType("application/json;charset=UTF-8");  
  if (null != str)  
    try {  
      response.getWriter().write(str);  
    } catch (IOException e) {  
      e.printStackTrace();  
    }  
}  

public static final void sendAsText(HttpServletResponse response, String str)  
{  
  response.setContentType("text/html;charset=UTF-8");  
  if (null != str)  
    try {  
      response.getWriter().write(str);  
    } catch (IOException e) {  
      e.printStackTrace();  
    }  
}  
posted @ 2016-04-25 01:09  机智的程序员小熊  阅读(441)  评论(0编辑  收藏  举报