zoukankan      html  css  js  c++  java
  • Android之Json

    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)

  • 相关阅读:
    C# Process执行bat
    Auto Clear Unity Console Log
    Unity原厂讲师大解密
    setSystemUiVisibility() 与 getSystemUiVisibility() 显示隐藏状态栏
    Android 6.0 动态权限申请
    Android6.0动态权限申请步骤以及需要注意的一些坑
    基于Rebound制造绚丽的动画效果-入门篇
    Rebound-Android的弹簧动画库
    Rebound动画框架简单介绍
    让动画不再僵硬:Facebook Rebound Android动画库介绍
  • 原文地址:https://www.cnblogs.com/zyxiaohuihui/p/4540602.html
Copyright © 2011-2022 走看看