gpt4 book ai didi

java - 如何在不使用javascript的情况下在html页面中显示密码错误错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:27:23 25 4
gpt4 key购买 nike

我想在html页面中显示密码错误错误,我可以使用requestdispatcher在不同的页面中执行此操作,但如何仅使用java和html在同一登录页面中显示它,我对javascript一无所知,谢谢

HTML 代码:

<p>Sign into your account</p>
<form action="bs" align="center" method="POST" onSubmit="return
validateLogin()">
<input type="text" name="u_name" placeholder="Username"><br>
<input type="password" name="pswd2" placeholder="Password"><br>
<br>
<input type="submit" value="Login!" >
<span style="color:red;">${errMsg)</span>
</form>

Servlet 代码:

 if(rs.next())
{
ResultSet rs1=stmt.executeQuery(vsql1);

if(rs1.next())
{
out.println("----Welcome----");
}
else
{
request.setAttribute("errMsg", "Invalid username or password");
RequestDispatcher dispatcher = request.getRequestDispatcher("login.html");
dispatcher.forward( request, response);
}
}
else
{
request.setAttribute("errMsg", "Invalid username or password");
RequestDispatcher dispatcher = request.getRequestDispatcher("login.html");
dispatcher.forward( request, response);
}

}

最佳答案

PrintWriter out=new PrintWriter();out.println("密码不匹配);

它将在浏览器中显示该值

关于java - 如何在不使用javascript的情况下在html页面中显示密码错误错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50390929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com