+ -
当前位置:首页 → 问答吧 → 怎样用struts2的action中用jdom向客户端输出XML,新手求大家帮忙 谢谢~~~

怎样用struts2的action中用jdom向客户端输出XML,新手求大家帮忙 谢谢~~~

时间:2011-08-29

来源:互联网

这是我自己构建好对象之后写得输出
HttpServletResponse resp = ServletActionContext.getResponse();
resp.setContentType("text/xml, charset=utf-8");
resp.setHeader("cache-control", "no-cache");
resp.setHeader("pragma", "no-cache");

PrintWriter out = resp.getWriter();
Format format = Format.getPrettyFormat();
XMLOutputter writer = new XMLOutputter(format);
writer.output(document, out);
浏览器没有收到响应 新手 求大家帮忙 谢谢~~~

作者: fyxtc   发布时间: 2011-08-29

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

这个貌似有点问题吧
text/xml; charset=utf-8

作者: izard999   发布时间: 2011-08-29