无须设置CONTENT_TYPE,只需要用ServletOutputStream向外写就可以了
String strXMLContent = "XML内容";Servlet中如下
ServletOutputStream sos = response.getServletOutputStream();
sos.write(strXMLContent.getBytes());
sos.close();这样IE就可以识别XML了,但如要正确展现,还需要XSL文件,在XML中指定XSL路径就可以了
String strXMLContent = "XML内容";Servlet中如下
ServletOutputStream sos = response.getServletOutputStream();
sos.write(strXMLContent.getBytes());
sos.close();这样IE就可以识别XML了,但如要正确展现,还需要XSL文件,在XML中指定XSL路径就可以了
<%
String contentStr = "ABCDEFGHI";
// 设为 utf-8 编码:
response.setContentType("application/xml; charset=UTF-8"); out.println("<html><head>abc</head><body>");
out.print(contentStr);
out.println("</body></html>");
%>IE6下面输出:
- <html>
<head>abc</head>
<body>ABCDEFGHI</body>
</html>