zl程序教程

您现在的位置是:首页 >  Java

当前栏目

ajax后台处理响应(java)

2023-04-18 15:02:28 时间
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();  
    }  
}