⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.jsp

📁 JSPshop JSPshop JSPshop
💻 JSP
字号:
<%@ page language="java" contentType="text/html;charset=gb2312" import="wssd.*,java.sql.*"%>
<jsp:useBean id="db" class="wssd.connectDB" />
<jsp:useBean id="wb" class="wssd.wssdDB" />
<html>
<head>
<title>用户登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
	function go(para)
	{
		if(para == 1)
		{
			if(add_form.username.value.length == 0 || add_form.password.value.length == 0)
			{
				alert("不能为空");
			}
			else
			{
				add_form.submit();
			}
		}
		if(para == 2)
		{
			add_form.reset();
		}
	}
</script>
</head>
<body>
<%
	String name = request.getParameter("username");
	String psw = request.getParameter("password");
	if(name == null || name.length() == 0)
	{
		%>
		<form name="add_form" action="login.jsp" method="post">
		<table>
		<tr>
		<td class="text-login" align="right">用户名:</td>
		<td class="text-login"><input type="username" name="username" class="inputlength120"></td>
		</tr>
		<tr>
		<td class="text-login" align="right">密码:</td>
		<td class="text-login"><input type="password" name="password" class="inputlength120"></td>
		</tr>
		<tr>
		<td class="text-login"><input type="button" value="登陆" onclick="go(1)" class="logbutton"></td>
		<td class="text-login"><input type="button" value="重填" onclick="go(2)" class="logbutton"></td>
		</tr>
		</table>
		</form>
		<%
	}
	else
	{
			int i = wb.checklogin(name,psw);
			if(i != 0)
			{
				session.setAttribute("username",name);
				session.setAttribute("user_id",String.valueOf(i));
				shopping shoplist = new shopping();
				shoplist.setShoplist();
				session.setAttribute("shoplist",shoplist);
				%>
				<script language="javascript">
					alert("登陆成功");
					window.close();
					opener.location.reload();
				</script>
				<%
			}
			else
			{
				session.removeAttribute("username");
				session.removeAttribute("user_id");
				session.removeAttribute("shoplist");
				%>
				<script language="javascript">
					alert("登陆不成功");
					window.close();
					opener.location.reload();
				</script>
				<%
			}
	}
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -