import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
public class Echarts extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("哈尔滨");
arrayList.add("北京");
arrayList.add("上海");
String jsonString = JSON.toJSONString(arrayList);//把map转为json数据
ArrayList<Integer> arrayList2 = new ArrayList<Integer>();
arrayList2.add(20);
arrayList2.add(50);
arrayList2.add(30);
String jsonString2 = JSON.toJSONString(arrayList2);//把map转为json数据
request.setAttribute("dizhi", jsonString.toString());
request.setAttribute("shuzi", jsonString2.toString());
System.out.println(jsonString);
System.out.println(jsonString2);
RequestDispatcher rd = request.getRequestDispatcher("echarts.jsp");
rd.forward(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}