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