Android之Json
2015-05-30 16:53
531 查看
Servlet部分
详见(android_json)
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)
相关文章推荐
- Duang~ Android堆栈慘遭毁容?精神哥揭露毁容真相!
- Android开发中的MVC设计模式
- Android PullToRefresh (ListView GridView 下拉刷新) 使用详解
- Android 自定义ScrollView ListView 体验各种纵向滑动的需求
- android项目中错误 java.lang.NoClassDefFoundError
- Android大牛们的博客
- Android——showAsAction()
- android无标题全屏的三种设置方式
- android中的显式与隐式Intent
- Android之在Layout中自定义View
- 教你搞定Android自定义View
- Android实战简易教程-第四枪(ScrollView和HorizontalScrollView动态添加控件并提供事件监听)
- Android自定义Layout
- Android开发-将自定义View布局到Layout中并调用
- Android学习笔记之自定义Toast
- 全国首发 | 腾讯Bugly携手极客学院,「Android Crash 跟踪方法」强势上线!
- Android自定义View onMeasure
- Android学习笔记之Fragment的两种使用方法
- android:layout_weight为0
- Android 5.0 来了,你的应用准备好了么?