<%@ page language="java" contentType="text/xml; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%>
<%
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.println("<root>");
out.println("<node id=\"1\"/>");
out.println("<node id=\"2\"/>");
out.println("</root>");
out.close();
%>
很简单的一段代码,输出responseText看了下,正常,奇怪,把responseText用特殊符号夹起来,终于发现前面多了个换行,看看代码,只有pageEncoding后面的%>那可能有点问题,于是把后面的<%提到前面,代码为
<%
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.println("<root>");
out.println("<node id=\"1\"/>");
out.println("<node id=\"2\"/>");
out.println("</root>");
out.close();
%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" import="java.util.*" pageEncoding="UTF-8"%><%
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.println("<root>");
out.println("<node id=\"1\"/>");
out.println("<node id=\"2\"/>");
out.println("</root>");
out.close();
%>
再用ajax取一下,终于好了,很有意思的问题,记一下。
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.println("<root>");
out.println("<node id=\"1\"/>");
out.println("<node id=\"2\"/>");
out.println("</root>");
out.close();
%>