springboot登录密码错误保留用户名

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot登录密码错误保留用户名相关的知识,希望对你有一定的参考价值。

SpringBoot登录密码错误时,可以保留用户名,只需要在数据库中设置一个变量即可,然后在登录页面获取该变量值来显示用户名。 参考技术A 建议通过一键恢复系统。

2,在关机的情况下,按电源开关键旁边的小键(像个转弯的箭头的),这时就会进入一键恢复的系统,耐心等候一会。

3,进入了一键恢复的操作界面,就会看到两个选项恢复出厂备份和恢复用户备份,一般选择恢复出厂备份,然后按照提示一步一步进行,就可以恢复到正常的系统。

4,注意事项:在还原的过程中,笔记本电池电量要充足或是在连接充电器的情况下进行。

JavaWeb登录表单提交的用户名密码的错误处理

private void login(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
String userName=request.getParameter("userName");
String userPass=request.getParameter("userPass");
String path = request.getContextPath();
HttpSession session= request.getSession();
User user=dao.select(userName, userPass);
if(user!=null)
//登录成功跳转至manage.jsp页面
session.setAttribute("user", user);
response.sendRedirect(path+"/manage/manage.jsp");
else
//登录失败,重新跳转login页面,提示用户名密码错误
response.sendRedirect(path+"/manage/login.jsp");
//请问怎么在这里处理用户密码错误之后返回到JSP页面之后给出提示呢。


JSP页面部分代码
<form action="UserServlet?op=login" method="post">
<div id="header">登录信息</div>
<table width="407" border="0" align="center">
<tr>
<td width="155" rowspan="4"><img src="manage/img/007.jpg"/></td>
<td width="63">用户名:</td>
<td width="175"><input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="password" name="userPass" id="userPass"></td>
</tr>
<tr>
<td colspan="2">请输入用户名和密码。</td>
//返回到这个页面之后。上面的一段字符串修改成 用户名密码错误

</tr>
<tr>
<td > </td>
<td align="right"><input type="submit" name="login" id="login" value="登 录">
<input type="reset" name="chongzhi" id="chongzhi" value="重 置"></td>
</tr>
</table>
</form>

页面转向时,使用forward而不是redirect,这样就可以把原来的用户名和密码再传到login.jsp页面,而且可以通过request.setAttribute()和request.getAttribute()来返回一些错误信息 参考技术A response重定向要传参数只能用连接后面挂参数的方式
一般采用1楼所诉的方式就可以了

以上是关于springboot登录密码错误保留用户名的主要内容,如果未能解决你的问题,请参考以下文章

在CRT中用SSH登录ASA怎么总是显示用户名和验证密码错误啊?怎么解决呢?

springboot + shiro 尝试登录次数限制与并发登录人数控制

基于SpringBoot的QQ邮箱登录注册及找回密码

Spring Boot,使用编码密码实现登录

springboot怎么进行非空验证之后再进行ajax登录

SpringBoot注册登录:注册--验证账号密码是否符合格式及后台完成注册功能