用ajax java后台传回值,包括传json
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();
}
}
标签:java,HttpServletResponse,getWriter,ajax,str,catch,传回,response
From: https://blog.51cto.com/u_2465818/6209767