Created
July 4, 2015 02:52
-
-
Save jew3lz/8f1aeaa50265978d8e20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/login/{code}", method = RequestMethod.GET) | |
public Map<String, Object> login(@PathVariable("code") String code, @RequestHeader("name") String name, | |
@RequestHeader("passwd") String passwd, Model model, HttpSession session) { | |
Map<String, Object> map = new HashMap<>(); | |
map.put("login", false);//标示登陆失败 | |
//检查验证码 | |
String scode = (String) session.getAttribute("scode"); | |
System.out.println("用户名:" + name); | |
System.out.println("密码:" + passwd); | |
System.out.println("用户输入:" + code); | |
System.out.println("session:" + scode); | |
if (!code.toUpperCase().equals(scode)) { | |
map.put("code_error", "验证码错误"); | |
return map; | |
} | |
//检查账号密码 | |
Admin admin = adminDao.findByCode(name); | |
System.out.println("admin:" + admin); | |
if (admin != null && passwd.equals(admin.getPassword())) { | |
//放入当前操作者 | |
System.out.println("success"); | |
session.setAttribute("user", name); | |
map.put("login", true); | |
return map; | |
} else { | |
map.put("error", "用户名或密码不正确"); | |
return map; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment