一、创建jsp文件?
创建登录界面 index.jsp
<%--
Created by IntelliJ IDEA.
User: HASEE
Date: 2021/10/21
Time: 17:41
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录</title>
<style>
table {
text-align: center;
margin: 150px auto 0;
font-size: 22px;
}
tr {
width: 250px;
height: 50px;
}
input {
width: 200px;
height: 30px;
border: 2px solid #000;
}
.subMint {
width: 60px;
height: 35px;
font-size: 20px;
}
.reset {
margin-left: 10px;
width: 60px;
height: 35px;
font-size: 20px;
}
strong {
font-size: 25px;
}
</style>
</head>
<body>
<form action="MyServletProject" method="post">
<table>
<tr>
<td colspan="2"> <strong>登录</strong></td>
</tr>
<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="2"><input type="submit" value="登录" class="subMint" >
<input type="reset" value="重置" class="reset" >
</td>
</tr>
</table>
</form>
</body>
</html>
创建登录成功界面success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录成功</title>
<style>
h1 {
text-align: center;
}
</style>
</head>
<body>
<h1>欢迎<%=request.getParameter("userName")%>登录</h1>
</body>
</html>
创建登录失败界面file.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录失败</title>
</head>
<body>
<h3>登录失败 <a href="index.jsp">重新登录</a></h3>
</body>
</html>
创建服务器MyServletProject.java
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet ("/MyServletProject")
public class MyServletProject extends HttpServlet {
public MyServletProject() {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String userName= (String) req.getParameter("userName");
String passWord= (String) req.getParameter("passWord");
String myUser="text";
String myPassWord="123";
System.out.println(userName+passWord);
if ( userName.equals(myUser)&&passWord.equals(myPassWord))
{
// 请求转发,重新定向
resp.sendRedirect("success.jsp?userName="+userName);
}
else {
// 请求转发
req.getRequestDispatcher("file.jsp").forward(req,resp);
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req,resp);
}
}
2.运行结果
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。