java_web/learn1/web/login/login.jsp
2024-12-03 01:21:51 +08:00

40 lines
1.2 KiB
Plaintext

<%--
Created by IntelliJ IDEA.
User: 25589
Date: 2024/12/1
Time: 下午11:58
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
</head>
<body>
<div class="login-card">
<h1>登录</h1>
<form action="${pageContext.request.contextPath}/UserLoginAction" method="POST">
<label for="username-input">用户名</label>
<input type="text" name="username" id="username-input">
<label for="password-input">密码</label>
<input type="password" name="password" id="password-input">
<input type="submit" value="登录">
</form>
</div>
</body>
<script>
<%
String loginFlag=request.getParameter("loginflag");
String username=request.getParameter("username");
if(loginFlag==null){ //无登录失败标识,是正常访问登录页面
loginFlag="";
}
if(loginFlag.equals("1")){
out.println("alert('用户【"+username+"】不存在!')");
}else if(loginFlag.equals("2")){
out.println("alert('密码错误!')");
}
%>
</script>
</html>