当前位置: 代码迷 >> Ajax >> java 用ajax java后盾传回值
  详细解决方案

java 用ajax java后盾传回值

热度:326   发布时间:2012-12-18 12:43:41.0
java 用ajax java后台传回值

?

? ? 用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();
      }
  }
?
  相关解决方案