看firebug的提示信息,以为是js的语法错误,可是怎么修改,发现还是不管用,事实上错误不是由于本地的语法错误而是服务器返回错误的json数据而已,在这种情况下可以用firebug跟踪服务器端的相应来找到相应的错误根源。
要提交返回的响应中,设置:
Content-type 为 "text/html"
参考代码如下:
public void renderHtml(String content) {
PrintWriter out = null;
try {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
out = response.getWriter();
out.write(content);
out.flush();
} catch (IOException e) {
log.error(e);
}finally{
if(out!=null){
out.close();
}
}
}
采用以上方式将处理好的json进行输出,问题解决。