本人初级小菜鸟一枚,在最近的学习中,练习套模板,在登录验证中有所感悟,所以写下来,写的不好的话请见谅
其中user是我的用户信息表
Controller中的代码
//登录验证
@RequestMapping(value = "dologin")
@ResponseBody
public JSONObject dologin(HttpServletRequest request,Model model) {
HttpSession session = request.getSession();
JSONObject json = new JSONObject();
String uname = request.getParameter("uname");//获取数据库内姓名信息
String pwd = request.getParameter("pwd");//获取数据库内密码信息
String code = request.getParameter("code").toLowerCase();//获取您在文本框输入的验证码信息 .toLowerCase 转为小写,因为服务器内的验证码默认为全部小写
if (!code.equals(session.getAttribute("verCode"))) {
//与下面生成的验证码对比
json.put("succes",