Login.jsp 页面:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"
%>
<%@ page import="java.text.*" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>用户登录</h1>
<!-- 明文的方式通过URL提交数据 -->
<form action="dologin.jsp" name="loginForm" method="get">
<!-- 将提交的数据封装在HTML header 中,再提交 -->
<form action="dologin.jsp" name="loginForm" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td colspan="8"><input type="submit" name="登录"/></td>
</tr>
</table>
</form>
</body>
</html>
dologin.jsp页面:
<body>
<h1>登录成功</h1>
</body>
使用get方法:
使用post方法: