为了账号安全,请及时绑定邮箱和手机立即绑定

登录页面 登录失败弹窗提示账号密码错误 并调回登陆页面问题

登录页面 登录失败弹窗提示账号密码错误 并调回登陆页面问题

RISEBY 2019-02-25 00:15:32
请大神帮忙编写代码 跪谢@Controller@RequestMapping("/*")public class UserAction { @RequestMapping("login.action") public String login(HttpSession session,String username,String password,RedirectAttributes ra,String yzm){ Map<String, Object> parmas=new HashMap<String, Object>(); String sessionYzm=(String) session.getAttribute("verCode"); if(yzm.toLowerCase().equals(sessionYzm)){ }else{ return "redirect:/jsp/login.jsp"; } parmas.put("logname", username); parmas.put("logpwd", password); User user=userService.slectUserByLognameAndLogpwd(parmas); if(user==null){ return "redirect:/jsp/login.jsp"; } String name=user.getLogname(); String pass=user.getLogpwd(); if(username.equals(name)&& password.equals(pass)){ return "main"; }else{ return "redirect:/jsp/login.jsp"; } } } jsp页面: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>登陆页面</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <link rel="stylesheet" href="css/bace.css"> <link rel="stylesheet" href="css/common.css"> <link rel="stylesheet" href="css/login.css"> <script type="text/javascript" src="js/jquery.js"></script> </head> <body> <div class="wrapper"> <!-- 头部logo --> <header> <img src="images/1.png" alt="logo" class="logo"> <img src="images/2.png" alt="舆情查询系统" class="title"> </header> <!-- 内容登录区域 --> <section style=""> <div class="nav"> <!-- 内容区域logo标志 --> <img src="images/1.png" alt=""> </div> <p class=""><span></span>用户登录<i></i></p> <form action="login.action" method="post" id="myForm" novalidate="novalidate"> <div class="mt15"> <label for="">用户名:&nbsp;&nbsp;</label><input type="text" name="username" value="" placeholder="请输入账号" required="required" maxlength="20" data-msg-maxlength="用户名最多为20个字符" data-msg-required="用户名不能为空" minlength="2" data-msg-minlength="用户名最少为2个字符" > </div> <div class="mt15"> <label for="" style="margin-right:2px;">密&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;</label><input type="text" name="password" value="" placeholder="" class="" required="required" maxlength="20" data-msg-maxlength="密码最多为20个字符" data-msg-required="密码不能为空" minlength="2" data-msg-minlength="密码最少为2个字符" > <a href="" class="col_el3 p10" >忘记密码</a> </div> <div class="mt15 "> <label for="">验证码:&nbsp;&nbsp;</label><input type="text" name="yzm" value="" class="mr15 w90" required="required" maxlength="4" data-msg-maxlength="密码为4个字符" data-msg-required="密码不能为空" minlength="4" data-msg-minlength="密码为4个字符" > <!-- <div id="msg"> </div> --> <img id="yzm" alt="点击刷新" title="点击刷新" src="creatYzm.action" style="height: 30px;width: 74px;position: absolute;cursor:pointer" onclick="refresh()"> </div> <div class="mt40 btn ml10" > <input type="submit" value="注册" class="mr15" > <input type="submit" value="登录" class="" > </div> </form> </section> <!-- 底部的版权 --> <footer> <img src="images/3.png" alt=""> </footer> </div> </body> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/messages_cn.js"></script><script type="text/javascript"> function refresh(){var refreshUrl="creatYzm.action?"+new Date(); $("#yzm").attr("src",refreshUrl);} $().ready(function() { $("#myForm").validate(); });</script></html>
查看完整描述

1 回答

?
墨色风雨

TA贡献1853条经验 获得超6个赞

代码就不帮你编写了。只是简单说一下,你完全可以采用异步的方式登陆,请求的时候做好加密等安全性措施的处理。后台处理玩后再在异步的回调里处理,成功跳转到你想去的画面,失败给出提示。

另外springmvc的@RequestMapping 写的是请求的url,你这么写【@RequestMapping("login.action")】.action应该交给spring去拦截。

查看完整回答
反对 回复 2019-03-01
  • 1 回答
  • 0 关注
  • 6800 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信