软件1班20240607
package com.yanyu;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
public class Login extends HttpServlet {
// 重写 父类方法 ctrl o
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// super.doGet(req, resp); 调用 父类的方法 super == 父类 的对象
// 设置 响应的类型和 编码格式
/* 浏览器 --》 服务器 的 数据 request
服务器 --》 浏览器 的 数据 response
* request
* response
* */
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
// 获取响应对象
PrintWriter out = response.getWriter();// ctrl alt v
// out.println("<html lang=\"en\">");
out.println("hello3");
// 多行 编辑 alt 鼠标拖动
out.println(" <!DOCTYPE html>");
out.println("");
out.println("<head>");
out.println(" <meta charset='UTF-8'>");
out.println(" <meta http-equiv='X-UA-Compatible' content='IE=edge'>");
out.println(" <meta name='viewport' content='width=device-width, initial-scale=1.0'>");
out.println(" <title>Document</title>");
out.println("</head>");
out.println("<body>");
out.println(" <h1>登录界面</h1>");
out.println(" <form action='/list'>");
// src = href = action 都是 路径 都是 url
out.println(" 账号<input type='text' name='username' >");
out.println(" <br>");
out.println(" 密码<input type='password' name='password' >");
out.println(" ");
out.println(" <br>");
out.println(" <input type='submit' value='登录'>");
out.println(" </form>");
out.println("</body>");
out.println("</html>");
}
}