今天接触了request.getParameter,当堂练习是简单的两个网页,一个表单登录界面,一个登录成功界面,一个Servlet界面,运行后可以进入登录界面,可是就是不能登录跳转,由于不认真,四五个小时才发现哪里的问题。
response.setContentType("text/html;charset=UTF-8");
String username=request.getParameter("username");
String password=request.getParameter("password");
if("a".equals(username)&&("111").equals(password)){
response.sendRedirect("/request/1.html");
}else{
response.sendRedirect("/request/2.html");
}
这一段正确
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="/request/jh" method="POST">
用户名:<input type="text" name="username"><br/>
密码:<input type="password" name="password"><br/>
<input type="submit" name="submit" value="提交">
<input type="reset" name="reset" value="重置">
</form>
</body>
</html>
出问题的是这里,本来没有红色区域,被自己蠢到了。