解决方法是关闭response的writer。
下面是ajax代码
$j.ajax({type : “POST”,url : “/asi/jsonCarrier.jsp”,data : {“artistId”:”${artistID}”}, //这里从session里拿出了artistID变量,用的是el表达式datatype : “text”,timeout: 10000,success : function(data) {if (data!=”” && data!=null){var dataArr = data;var jsonData = dataArr.statistics;var priceData = [];var volumeData = [];var summaryData = [];$j.each(jsonData, function(i, dataItem) {priceData[i] = [ i, dataItem.beta ];volumeData[i] = [ i, dataItem.volume ];summaryData[i] = [ i, dataItem.volatility ];});$j(“#artistName”).html(dataArr.meta.artist_forename+” “+dataArr.meta.artist_surname);displayGraph(jsonData, priceData, volumeData, summaryData);}},error : function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}})
下面是 jsonCarrier.jsp里的java代码