码迷,mamicode.com
首页 > 移动开发 > 详细

Android之Json

时间:2015-05-30 17:55:25      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

Servlet部分

技术分享

public class JasonAction extends HttpServlet {

    private JsonService service;
    
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.doPost(request,response);
        
    }

    /**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        PrintWriter out = response.getWriter();
        System.out.println("sd");
        //String jsonString = JsonTools.createJsonString("person", service.getlistPerson());
        String jsonString = "";
        String action_flag = request.getParameter("action_flag");
        if(action_flag.equals("person")){
            jsonString = JsonTools.createJsonString("person",service.getPerson());
        }else if(action_flag.equals("persons")){
            jsonString = JsonTools.createJsonString("persons",service.getlistPerson());
        }else if(action_flag.equals("liststring")){
            jsonString = JsonTools.createJsonString("liststring",service.getListString());
        }else if(action_flag.equals("listmap")){
            jsonString = JsonTools.createJsonString("listmap",service.getListMaps());
        }
        System.out.println(jsonString);
        out.print(jsonString);
        out.flush();
        out.close();
    }

    @Override
    public void init() throws ServletException {
        // TODO Auto-generated method stub
        service = new JsonService();
    }
}

技术分享

详见(android_json)

Android之Json

标签:

原文地址:http://www.cnblogs.com/zyxiaohuihui/p/4540602.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!