Login 页面
1、jsp
<script type="text/javascript">
function doLogin() {
if (trim($('#username').val()) == "") {
showmsg(0, "请输入用户名");
return;
}
if (trim($('#password').val()) == "") {
showmsg(0, "请输入密码");
return;
}
$.ajax({
url : "${contextPath}/web/login.htm",
data : $("#loginForm").serialize(),
cache : false,
success : function(xmlHttp) {
var res = xmlHttp;
if (res.errorMessage && res.errorMessage != "") {
showmsg(0, res.errorMessage);
} else {
if (str_isblank(res.status)) {
showmsg(1, "登录成功!");
window.setTimeout("window.location='${contextPath}/web/toindex.htm'", 1500);
} else {
showmsg(1, "登录成功!");
var fromUrl = res.status;
location.href = fromUrl;
}
}
}
}); } </script>
2.controller
@RequestMapping("/tologin.htm")
public String tologin(HttpSession session, RequestParameter param) {
if (!StringUtils.isBlank(param.getBackurl())) {
if (httpSession.getAttribute("NOLOGIN_SHOP_URL") != null) {
httpSession.removeAttribute("NOLOGIN_SHOP_URL");
}
httpSession.setAttribute("NOLOGIN_SHOP_URL", param.getBackurl());
if (param.getBackurl().endsWith("logout.htm"))
httpSession.setAttribute("NOLOGIN_SHOP_URL", "");
}
return "web/login";
}
@RequestMapping("/login.htm")
@ResponseBody
public Response login(Model model, RequestParameter param, InfoUser infoUser) {
Response res = new Response();
SessionUser suser = null;
if (httpSession.getAttribute(WebConstants.SESSION_USER_KEY) != null) {
suser = new SessionUser();
suser = (SessionUser) httpSession.getAttribute(WebConstants.SESSION_USER_KEY);
}
if (null == suser || StringUtils.isBlank(suser.getUsername())) {
// #0: 正常;
// #1: 用户名不存在;
// #2:密码不正确;
Integer ret = webService.loginInfoUser(infoUser);
if (ret == 1) {
res.setErrorMessage("登录失败,用户名不存在。");
} else if (ret == 2) {
res.setErrorMessage("登录失败,密码不正确。");
} else { // 登录成功,写session
InfoUser infoUser1 = webService.getInfoUserByName(infoUser.getUsername());
suser = new SessionUser();
suser.setUserid(infoUser1.getUserid());
suser.setUsername(infoUser1.getUsername());
//suser.setPhonenum(infoUser1.getPhonenum());
httpSession.setAttribute(WebConstants.SESSION_USER_KEY, suser);
if (httpSession.getAttribute("NOLOGIN_SHOP_URL") != null) {
String backurl = (String) httpSession.getAttribute("NOLOGIN_SHOP_URL");
res.setStatus(backurl);
httpSession.removeAttribute("NOLOGIN_SHOP_URL");
}
}
}
return res;
}
Login 页面的更多相关文章
- 没有login页面
"/"应用程序中的服务器错误. 无法找到资源. 说明:HTTP 404.您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用.请检查以下 URL 并确保 ...
- mvc ajax访问后台时session过期无法跳转到Login页面问题解决
public class BaseController : Controller { protected User UserInfo { set { Session["UserInfo&qu ...
- 一个Login页面全面了解session与cookie
背景 做了四年的前端开发,对外一直说自己是web开发,那么身为一个web开发怎能不知道session与cookie以及其管理方式呢~ Login涉及技术栈:Nodejs,MongoDB,Express ...
- [py][mx]django get方法返回login页面
get方法返回login.html users/views.py def login(request): if request.method == "POST": pass eli ...
- 《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件
实战 上接,笔记:https://blog.csdn.net/u010132177/article/details/104150177 https://gitee.com/pasaulis/react ...
- JavaWeb网上图书商城完整项目--day02-14.登录功能的login页面处理
1.现在注册成功之后,我们来到登录页面,登录页面在于 在登录页面.我们也需要向注册页面一样对登录的用户名.密码 验证码等在jsp页面中进行校验,校验我们单独放置一个login.js文件中进行处理,然后 ...
- MVC4.0 使用Form认证,自定义登录页面路径Account/Login
使用MVC4.0的时候,一般遇到会员登录.注册功能,我们都会使用Form认证,给需要身份验证的Action进行授权(需要登录后才能访问的Action添加[Authorize]属性标签),登录.注册的时 ...
- MVC程序部署后页面指向login.aspx
MVC程序在本地没有问题,但是部署到服务器后老是跳转到Login.aspx页面,但是我的MVC程序中根本没有Login页面,看了一下链接是这样的 htttp://localhost:26290/log ...
- Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken
在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...
随机推荐
- 安全漏洞API接口
这个是avfisherapi写的API,经常用,每次找他的博客都搜到AV,尴尬..在这里记下来. 0x01 查询最新安全事件和漏洞的接口 接口URL: 乌云网: http://avfisherapi. ...
- eclipse下添加viplugin插件的方法
http://www.viplugin.com/ 在eclipse根目录下建立文件:viplugin2.lic,然后在里面添加以下字符串: nd4UFjUMBADcUSeSW8ocLKoGP3lpbW ...
- CentOS7_RAID5_LVM_SAMBA
1.在CentOS 7上构建RAID5.LVM和SAMBA服务器(1)——预备http://blog.csdn.net/kingfox/article/details/51099617 2.在Cent ...
- [转载] 理解RESTful架构
原文: http://www.ruanyifeng.com/blog/2011/09/restful.html 理解RESTful架构 作者: 阮一峰 日期: 2011年9月12日 越来越多的人开 ...
- poj1329Circle Through Three Points(三角形外接圆)
链接 套模板 不知道有没有x,y=0情况,不过这种情况都按+号输出的. #include <iostream> #include<cstdio> #include<cst ...
- Jmeter使用之常用函数介绍
“_csvRead”函数 CsvRead函数是从外部读取参数,CsvRead函数可以从一个文件中读取多个参数. 下面具体讲一下如何使用csvread函数: 1. 新建一个csv或者text文件 ...
- 26个Jquery使用小技巧
下面列出了一些Jquery使用技巧.比如有禁止右键点击.隐藏搜索文本框文字.在新窗口中打开链接.检测浏览器.预加载图片.页面样式切换.所有列等高.动态控制页面字体大小.获得鼠标指针的X值Y值.验证元素 ...
- 代码中特殊的注释技术——TODO、FIXME和XXX的用处
本文内容概要: 代码中特殊的注释技术--TODO.FIXME和XXX的用处. 前言:今天在阅读Qt Creator的源代码时,发现一些注释中有FIXME英文单词,用英文词典居然查不到其意义!实际上, ...
- 统一事件源epoll代码示例
可以将信号注册进pipe管道的写端,通过对读端的监听,来实现统一事件源. #include <sys/types.h> #include <sys/socket.h> #inc ...
- PHP SPL标准库之SplFixedArray使用实例
SplFixedArray主要是处理数组相关的主要功能,与普通php array不同的是,它是固定长度的,且以数字为键名的数组,优势就是比普通的数组处理更快. 看看我本机的Benchmark测试: i ...