/** * @see 手机端登陆的接口 */
@Resource Loginservice loginService; //@Resource代表着引用资源
public void startLogin(){
Map<String,Object> map=new HashMap<String,Object>();
//得到请求对象
HttpServletRequest request=this.getRequest();
//拿到手机端传给我们的username这个key所对应的的value,用map装起来
map.put("username",request.getParameter("username"));
/拿到密码不为空就 吧它用MD5加密用map装起来,用MD5是为了账户安全,注册的时候都是加密了存入数据库的,简单防止剽窃
if(StringUtils.isNotNull(request.getParameter("password"))) {
String password = Md5Utils.MD5_32(request.getParameter("password"));
map.put("password", password);
}
//在这里就是Service去掉dao层,dao层掉ibatis(数据库层)经过数据库的查询得到一个这个人的信息,查不到返回空
String json = loginService.Loginmobile(map);
JSONObject jsonobj=new JSONObject();
if(json==null){
json="";
jsonobj.put("state", "false");
jsonobj.put("msg", "登陆失败,用户名或密码错误");
}else{
jsonobj.put("userinfo", json);
jsonobj.put("state", "true");
jsonobj.put("msg", "登陆成功");
}
//在这里输出,手机端就拿到web返回的值了
this.outJsonString(jsonobj.toString());
}