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 页面的更多相关文章

  1. 没有login页面

    "/"应用程序中的服务器错误. 无法找到资源. 说明:HTTP 404.您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用.请检查以下 URL 并确保 ...

  2. mvc ajax访问后台时session过期无法跳转到Login页面问题解决

    public class BaseController : Controller { protected User UserInfo { set { Session["UserInfo&qu ...

  3. 一个Login页面全面了解session与cookie

    背景 做了四年的前端开发,对外一直说自己是web开发,那么身为一个web开发怎能不知道session与cookie以及其管理方式呢~ Login涉及技术栈:Nodejs,MongoDB,Express ...

  4. [py][mx]django get方法返回login页面

    get方法返回login.html users/views.py def login(request): if request.method == "POST": pass eli ...

  5. 《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件

    实战 上接,笔记:https://blog.csdn.net/u010132177/article/details/104150177 https://gitee.com/pasaulis/react ...

  6. JavaWeb网上图书商城完整项目--day02-14.登录功能的login页面处理

    1.现在注册成功之后,我们来到登录页面,登录页面在于 在登录页面.我们也需要向注册页面一样对登录的用户名.密码 验证码等在jsp页面中进行校验,校验我们单独放置一个login.js文件中进行处理,然后 ...

  7. MVC4.0 使用Form认证,自定义登录页面路径Account/Login

    使用MVC4.0的时候,一般遇到会员登录.注册功能,我们都会使用Form认证,给需要身份验证的Action进行授权(需要登录后才能访问的Action添加[Authorize]属性标签),登录.注册的时 ...

  8. MVC程序部署后页面指向login.aspx

    MVC程序在本地没有问题,但是部署到服务器后老是跳转到Login.aspx页面,但是我的MVC程序中根本没有Login页面,看了一下链接是这样的 htttp://localhost:26290/log ...

  9. Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken

    在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...

随机推荐

  1. Python字符串、元组、列表、字典互相转换的方法

    直接上代码!!!   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...

  2. linux下导入、导出mysql数据库命令

    一.导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径): 1.导出数据和表结构: mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql #/usr ...

  3. Java开发中经典的小实例-(随机数)

    import java.util.Random;//输出小于33的7个不相同的随机数public class probability {    static Random random = new R ...

  4. POJ 1142 Smith Numbers(史密斯数)

    Description 题目描述 While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Leh ...

  5. 未能加载文件或程序集“SQLDAL”或它的某一个依赖项。系统找不到指定的文件

    1. 检查是否SQLDAL.DLL这个程序集文件是否存在,是否在Debug目录下(如果你是在Debug模式下调试).或者看看是否是配置文件中的名称和实际的dll的名称不对应. 2. 你使用的是Asse ...

  6. Python基础学习笔记(六)常用列表操作函数和方法

    参考资料: 1. <Python基础教程> 2. http://www.runoob.com/python/python-lists.html 3. http://www.liaoxuef ...

  7. Maven中<dependencies>节点和<dependencyManagement>节点的区别 转

    以前一直没有在意,今天建立maven工程的时候在<dependencyManagement>节点下加入了junit依赖,结果在dependency Graph中没有发现junit的依赖关系 ...

  8. iOS - Swift 与 C 语言交互编程

    前言 作为一种可与 Objective-C 相互调用的语言,Swift 也具有一些与 C 语言的类型和特性,如果你的代码有需要,Swift 也提供了和常见的 C 代码结构混合编程的编程方式. 1.基本 ...

  9. iOS - Widget 小部件

    1.Widget iOS extension 的出现,方便了用户查看应用的服务,比如用户可以在 Today 的 widgets 中查看应用的简略信息,然后点击进入相关的应用界面. 2.添加 Widge ...

  10. mysql 聚集函数需要注意的问题

    1.当没有记录的时候,使用聚集函数,会导致出现一条记录,记录的取值都是NULL,如下:mysql> select name from student where name='David';Emp ...