<%-- Created by IntelliJ IDEA. User: Administrator Date: 2024/6/7 Time: 8:38 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %>Title 前往登录
aa com.yanyu.Login aa https://blog.csdn.net/demo/login bb com.yanyu.Demmo bb /list
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(""); out.println("hello3"); // 多行 编辑 alt 鼠标拖动 out.println(" "); out.println(""); out.println(""); out.println(" "); out.println(" "); out.println(" "); out.println(""); out.println(""); out.println(""); } }Document "); out.println(""); out.println(""); out.println("登录界面
"); out.println("
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; public class Demmo extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 获取 浏览器 的数据 request // 设置 请求 编码 request.setCharacterEncoding("utf-8"); String username = request.getParameter("username");// CTRL alt v String pass = request.getParameter("password");// CTRL alt v // 通过 name 属性的 值 username 去 拿到 账号 System.out.println(username);/// 打印到服务器控制台 4232354 System.out.println(pass);/// 打印到服务器控制台 4232354 } }
还没有评论,来说两句吧...