我在一个html中写如下代码:
<html>
    <head> <script type="text/javascript" charset="utf-8"
src="script/jquery-1.3.2.min.js">
        </script>
        <script type='text/javascript'>
                $.ajax({
                    type: "post",
url:"result.jsp",
datType:"xml",
data:{
s:'machine'
},
                    beforeSend: function(XMLHttpRequest){
                        //ShowLoading();
                    },
 async: false,
                    success: function(data, textStatus){
                        //$("#translation").html(data);
//alert(data.xml);
 $(data).find('record').each(function()
      {
      //alert(i);
      //得到各个字段内容
      var $book = $(this);
      var title=$book.find('dc\\:title').text();
  var url = 'http://s.wanfangdata.com.cn/paper.aspx?f=SimpleSearch&q='+escape(title) ;
      var Creator=$book.find('dc\\:Creator').text();
      var Date=$book.find('dc\\:Date').text();
      var source=$book.find('dc\\:source').text();
      var Description = $book.find('dc\\:Description').text();
  alert(title+url+Creator+Date+source+Description);
      });
                    },
                    complete: function(XMLHttpRequest, textStatus){
                        //HideLoading();

                    },
                    error: function(){
                        //请求出错处理
alert("error");
                    }
                });
        </script>
    </head>
    <body>
    </body>
</html>如果传进去的s参数是英文的话返回并解析xml没有问题,但是如果s是中文的话,在服务器的端的jsp页面打印出了正确内容,但是在上面的页面中却执行了错误处理,不知道是什么原因?下面是jsp的代码(涉及到公司的内部接口陷去了):<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="util.*"%>
<%@ page import="com.google.api.translate.*"%>
<%@page import="wf.yjy.zhxxj.*"%>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>
<%
String s = request.getParameter("s");
System.out.println("***********"+s);
s="title all \"自然\"";
s=URLEncoder.encode(s, "UTF-8");
System.out.println(s);
HttpConnect hc = new HttpConnect();
InputStream urlstream = hc
.doConncet(
"http://url"+s);
//text=new String(text.getBytes("ISO-8859-1"),"GB2312"); 
BufferedReader in = new BufferedReader(new InputStreamReader(
urlstream));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null) {
buffer.append(line);
System.out.println(line);
}
//System.out.println(buffer.toString());
PrintWriter out1;
//Thread.sleep(2000);
response.setContentType("application/xml");
response.setCharacterEncoding("utf-8");
response.setHeader("Cache-Control", "no-cache");
out1 = response.getWriter();
out1.println(buffer.toString());
%>