zoukankan      html  css  js  c++  java
  • JAVA框架-Servlet上

    package day27;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**

    • Servlet implementation class LoginServlet
      */
      @WebServlet("/LoginServlet")
      public class LoginServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;

      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      System.out.println("服务器收到get请求!");
      String username = request.getParameter("username");
      String password = request.getParameter("password");
      System.out.println("用户名:"+username );
      System.out.println("密码:"+ password);
      }

      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      System.out.println("服务器收到post请求!");
      String username = request.getParameter("username");
      String password = request.getParameter("password");
      System.out.println("用户名:"+username );
      System.out.println("密码:"+ password);
      }

    }

    /*
    服务器收到post请求!
    用户名:123
    密码:1111
    服务器收到get请求!
    用户名:1234
    密码:22222222
    */

  • 相关阅读:
    第四章 基础命令的学习
    7-7命令总结
    第三章 虚拟机的简单使用及其xshell远程工具的使用
    第二章 虚拟机的软件及其安装
    在VMware中安装CentOS系统步骤
    Pytest02-用法和调用
    Pytest01-从官方文档开始学习
    浅谈mock技术
    C/C++ malloc、calloc、realloc和alloca
    Go 知识汇总
  • 原文地址:https://www.cnblogs.com/JeasonIsCoding/p/13232607.html
Copyright © 2011-2022 走看看