android 与 服务器通信

  android 与 服务器通信

 服务端代码:

(1)control 层

 /**
     * 用户登录
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public String login(
            @RequestParam(value = "userName") String userName,
            @RequestParam(value = "userPassword") String userPassword,
            HttpSession httpSession){
      /*  int result = appUserInfoService.getAddr(request);*/
        try{
            System.out.println(userName+","+userPassword);
            User user = userService.login(userName,userPassword);
            if(user == null){
                return JSON.toJSONString(-1);//用户名密码错误
            }else{
                return JSON.toJSONString(user, SerializerFeature.DisableCircularReferenceDetect);//登录成功
            }
        }catch(Exception e) {
            return JSON.toJSONString(0);
        }
    }

  

(2)service  层

 

(3)Dao 层

(4)mapping层

参考博客:http://blog.csdn.net/qq_33171970/article/details/54956320

原文地址:https://www.cnblogs.com/1qazse4/p/7783524.html