struts.xml配置文件
<action name="builderXml" class="*Action"> <result name="xmlMessage" type="plaintext"></result> </action>
java代码:
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter pw = null;
try {
pw = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
pw.write(document.asXML());