servlet的Gson怎样传到网页中并使用

servlet的Gson怎样传到网页中并使用

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        ServerInitListener.ServletContextListener();
        WaterGate[] GateList=ServerInitListener.GateList;
        Gson gson = new Gson();
        //String t1=gson.toJson(GateList);
        int Gate_num=ServerInitListener.Gate_num;

gson只是json的工具,如果前端需要json字符串;把对应的实体转换成json串发给前端,前端把json串进行解析即可