ajax 返回Json方法

public static void sendJsonData(String data)
  {
    ActionContext ac = ActionContext.getContext();
    HttpServletResponse response = (HttpServletResponse)ac.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");
    response.setContentType("text/html;charset=utf-8");
    try {
      PrintWriter pw = response.getWriter();
      pw.print(data);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

 

posted on 2015-11-13 16:41  sierrajuan  阅读(163)  评论(0编辑  收藏  举报

导航