StringBuilder sheetName = new StringBuilder();
sheetName.append("{\"name\":[");
for(String s : list) {
sheetName.append("\"" + s + "\",");
}
sheetName.deleteCharAt(sheetName.length()-1);
sheetName.append("]}");
System.out.println(sheetName.toString());
// 返回格式
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(sheetName.toString());
return null; php
先将须要返回的内容转换成json格式。能够再http://www.bejson.com/go.php?u=http://www.bejson.com/index.php进行在线json格式验证。 json
在页面var data = eval('(' + data+ ')');有时须要经过这个函数进行转换 app