用户登录按钮,登录成功页面跳转,在跳转的URL中传递用户账号参数
JS代码如下:
/** * 用户登录 */ function login(){ var userAccount=$("#userAccount").val(); var userPassword=$("#userPassword").val(); if(isNull(userAccount)){ alert("请输入账号!"); $("#userAccount").focus(); $("#userAccount").css("background-color","#990000"); return false; } if(isNull(userPassword)){ alert("请输入密码!"); $("#userPassword").focus(); $("#userPassword").css("background-color","#990000"); return false; } //登录ajax $.ajax({ async:false, //同步请求,//默认为true 异步 type:"post",//提交方法 dataType:"json", url:"../admin/userLoginJsonAction!userLogin",//提交的地址 data:{"userAccount":userAccount,"userPassword":userPassword},//提交的参数 //失败回调函数 error:function(xmlHttp,status,errorThrown){ alert("status:"+status+",error : " + errorThrown); }, //成功后,回调的函数名 success:function(data){ //alert(data.userList[0].userAccount); if(isNull(data.userList[0].errorMsg)){ if(!isNull(data.userList[0].userAccount)){ alert("登录成功"); location.href = "adminIndex.jsp?userAccount="+userAccount;//location.href实现客户端页面的跳转 //window.open("adminIndex.jsp"); } else { alert("账号密码错误"); } } else { alert(data.userList[0].errorMsg); } } }); }
在另外一个界面接收用户账号参数,代码如下:
<div id="userInfo" class="">welcome <s:property value="#parameters.userAccount" /> <a href="">退出</a></div>