taotao用户登录(及登录成功后的回调url处理)
后台Controller:
package com.taotao.sso.controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; //页面跳转Controller
@Controller
@RequestMapping("/page")
public class PageController { //跳转到注册页面
@RequestMapping("/register")
public String showRegister() {
return "register";
} /**
* 跳转到登录页面
* @param redirect 登录成功后跳转的回调页面url
* @param model
* @return
*/
@RequestMapping("/login")
public String showLogin(String redirect,Model model) {
model.addAttribute("redirect", redirect);
return "login";
}
}
前台jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>登录淘淘</title>
<link type="text/css" rel="stylesheet" href="/css/login.css"/>
<script type="text/javascript" src="/js/jquery-1.6.4.js"></script>
</head>
<body>
<div class="w">
<div id="logo">
<a href="http://localhost:8082" clstag="passport|keycount|login|01">
<img src="/images/taotao-logo.gif" alt="淘淘" width="170" height="60"/>
</a><b></b>
</div>
</div>
<form id="formlogin" method="post" onsubmit="return false;">
<div class=" w1" id="entry">
<div class="mc " id="bgDiv">
<div id="entry-bg" clstag="passport|keycount|login|02" style="width: 511px; height: 455px; position: absolute; left: -44px; top: -44px; background: url(/images/544a11d3Na5a3d566.png) 0px 0px no-repeat;">
</div>
<div class="form ">
<div class="item fore1">
<span>用户名</span>
<div class="item-ifo">
<input type="text" id="loginname" name="username" class="text" tabindex="1" autocomplete="off"/>
<div class="i-name ico"></div>
<label id="loginname_succeed" class="blank invisible"></label>
<label id="loginname_error" class="hide"><b></b></label>
</div>
</div>
<script type="text/javascript">
setTimeout(function () {
if (!$("#loginname").val()) {
$("#loginname").get(0).focus();
}
}, 0);
</script>
<div id="capslock"><i></i><s></s>键盘大写锁定已打开,请注意大小写</div>
<div class="item fore2">
<span>密码</span>
<div class="item-ifo">
<input type="password" id="nloginpwd" name="password" class="text" tabindex="2" autocomplete="off"/>
<div class="i-pass ico"></div>
<label id="loginpwd_succeed" class="blank invisible"></label>
<label id="loginpwd_error" class="hide"></label>
</div>
</div>
<div class="item login-btn2013">
<input type="button" class="btn-img btn-entry" id="loginsubmit" value="登录" tabindex="8" clstag="passport|keycount|login|06"/>
</div>
</div>
</div>
<div class="free-regist">
<span><a href="/page/register" clstag="passport|keycount|login|08">免费注册>></a></span>
</div>
</div>
</form>
<script type="text/javascript">
var redirectUrl = "${redirect}";
var LOGIN = {
checkInput:function() {
if ($("#loginname").val() == "") {
alert("用户名不能为空");
$("#loginname").focus();
return false;
}
if ($("#nloginpwd").val() == "") {
alert("密码不能为空");
$("#nloginpwd").focus();
return false;
}
return true;
},
doLogin:function() {
$.post("/user/login", $("#formlogin").serialize(),function(data){
if (data.status == 200) {
alert("登录成功!");
if (redirectUrl == "") {//如果没有回调跳转到首页
location.href = "http://localhost:8082";
} else { //有回调,跳转到回调页面
location.href = redirectUrl;
}
} else {
alert("登录失败,原因是:" + data.msg);
$("#loginname").select();
}
});
},
login:function() {
if (this.checkInput()) {
this.doLogin();
}
} };
$(function(){
$("#loginsubmit").click(function(){
LOGIN.login();
});
});
</script>
</body>
</html>
页面:

如果有回调参数,则,输入用户名,密码后,点登录成功确认,会跳转到回调页面:

点确定:会跳转到百度:

taotao用户登录(及登录成功后的回调url处理)的更多相关文章
- miniui表格load数据成功后,回调函数,其中setData要用如下方法
init: function () { mini.parse(); this.grid = mini.get("jsDatagrid"); var grid1 = mini.get ...
- Android 集成ShareSDK分享QQ或空间成功后,回调却不执行的原因
AndroidMainifest.xml中的如箭头所示的id一定要与assets下ShareSDK.xml中配置的QQ的AppId一定要相同. 如下图
- IdentityServer4 登录成功后,跳转到原来页面
IdentityServer4 登录成功后,默认会跳转到Config.Client配置的RedirectUris地址http://localhost:5003/callback.html,用于获取 T ...
- httpclient 怎么带上登录成功后返回的cookie值访问下一页面
我是只很菜很菜的小鸟.刚上班,有这个一个需求.要我抓取别的网站的数据. 我根据用户密码登录一个网站成功后,生成一个cookie值.我已经获取到了.然后要带上这个cookie值进行下一页面的访问 ...
- 登录&单点登录介绍
COOKIE & SESSION & TOKEN 主要用来跟踪会话,识别用户所用.cookie 是客户端,session 是服务端的. 因为 http 是无状态协议,每一次的访问都不知 ...
- .net mvc 用jquery ajax成功后页面跳转。
$.ajax({ //url: 'http://192.168.0.102/webApiDemo/api/WebApiTest/PostStudentInforOnePara', //url: &qu ...
- cas 3.5.2 登录成功后,如何返回用户更多信息?
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- taotao用户登录springMVC拦截器的实现
在springMVC中写拦截器,只需要两步: 一.写 java 拦截器类,实现 interceptor 拦截器接口. 二.在 springMVC 的xml配置文件中,配置我们创建的拦截器对象及其拦截目 ...
- [原]基于CAS实现单点登录(SSO):登录成功后,cas client如何返回更多用户信息
从cas server登录成功后,默认只能从casclient得到用户名.但程序中也可能遇到需要得到更多如姓名,手机号,email等更多用户信息的情况. cas client拿到用户名后再到数据库中查 ...
随机推荐
- Go语言中的UDP应用
Go语言中的UDP应用 Go语言中使用UDP是很方便的,net包提供了UDP和TCP的功能,这里使用UDP做了一个UDP广播,然后接收各个设备的返回信息.实现起来很快,总体感觉比使用C#中的UDP更优 ...
- python2.7入门---模块(Module)
来,这次我们就看下Python 模块(Module).它是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句.模块让你能够有逻辑地组织你的 Pytho ...
- 使用java多线程分批处理数据工具类
最近由于业务需要,数据量比较大,需要使用多线程来分批处理,提高处理效率和能力,于是就写了一个通用的多线程处理工具,只需要实现自己的业务逻辑就可以正常使用,现在记录一下 主要是针对大数据量list,将l ...
- consul 使用方式
1.在配置文件配置好的情况下,在运行 consul agent -server -datacenter=([xacl.json].[acl_datacenter]) -bootstrap -data- ...
- 大数据培训班 cloudera公司讲师面对面授课 CCDH CCAH CCP
大数据助力成就非凡.大数据正在改变着商业游戏规则,为企业解决传统业务问题带来变革的机遇.毫无疑问,当未来企业尝试分析现有海量信息以推动业务价值增值时,必定会采用大数据技术. 目前对大数据的分析工具,首 ...
- sql插入查询出的数据,主键递增
INSERT INTO C_DPRECORD SELECT (SEQ_C_DPRECORD.NEXTVAL ) AS ID, DEV_ID, DEV_CHNNUM, DEV_NAME, DEV_CHN ...
- Hibernate-ORM:04.Hibernate中的get()和load()
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客会讲如何用get()或load()查询单个对象和对缓存的简单操作,以及他俩的区别和相同(前面有的那些配 ...
- 【jQuery】 实用 js
[jQuery] 实用 js 1. int 处理 parseInt(") // int 转换 isNaN(page) // 判断是否是int类型 2. string 处理 // C# str ...
- 云计算之路-阿里云上:奇怪的CPU 100%问题
这篇博文记录一下6月1日在阿里云上遇到的奇怪的CPU 100%问题,希望多年以后能真相大白. 那天负载均衡(SLB)中只放了1台云服务器(平时都放2台),由于是节假日,虽然只放了一台,但这台服务器的负 ...
- iOS-Debug Symbol(调试符号)
Debug Symbol(调试符号) 编译警告 从svn下载下来的文件,到处都是编译警告,看着不爽,找下原因,没想到还是一条大鱼 warning: (i386) /UsersLibrary/Devel ...