AJAX向Response流中输出Xml的办法
来源:优易学  2011-11-25 17:49:13   【优易学:中国教育考试门户网】   资料下载   IT书店

  public static void outPrint(Document doc, HttpServletResponse response) throws IOException {

  response.setCharacterEncoding("UTF-8");

  response.setContentType("text/xml; charset=utf-8");

  PrintWriter out = response.getWriter();

  OutputFormat format = OutputFormat.createCompactFormat();

  //去掉xml头

  //format.setSuppressDeclaration(true);

  //format.isPadText();

  format.setEncoding("utf-8");

  XMLWriter writer = new XMLWriter(out, format);

  writer.write(doc);

  writer.flush();

  writer.close();

  }

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训