标签:
1 $.ajax({
2 url:basepath+"/login/login?msg_base64="+msg_base64, 3 async: false, 4 // data:{ 5 // "formContent":str, 6 // "formName":formName, 7 // "leixing":leixing 8 // }, 9 dataType:"jsonp", 10 processData: false, 11 type:"get", 12 success:function(data){ 13 data=data[0]; 14 alert(data); 15 if(data.status=="0"){ 16 $("#usererror").html(data.msg); 17 }else if(data.status=="1"){ 18 $("#pwderror").html(data.msg); 19 } 20 else if(data.status=="2"){ 21 alert("水电费:"+data.data); 22 addCookie("token",data.data,1);//将令牌存入cookie中 23 window.location.href="edit.html"; 24 } 25 } 26 });
1 @ResponseBody // 将方法的返回结果自动转换为json格式字符串,注意需要导json的包 2 @RequestMapping(value = "/login", method = RequestMethod.GET) 3 public String login(HttpServletRequest request,String msg_base64) { 4 5 6 String callback=request.getParameter("callback"); 7 //System.out.println(callback); 8 // 信息 9 // String msg_context_base64 = msg_base64.split(" ")[1]; 10 String msg = NoteUtil.base64Decode(msg_base64);// 解密,解密后:username:password 11 String name = msg.split(":")[0]; 12 String pwd = msg.split(":")[1]; 13 NoteResult result = service.checkUser(name, pwd); 14 System.out.println("result "+result.toString()); 15 JSONArray json=JSONArray.fromObject(result); 16 System.out.println(" "+callback+"("+json+")"); 17 return callback+"("+json.toString()+")"; 18 } 19
标签:
原文地址:http://www.cnblogs.com/feiyuanxing/p/4575888.html