zoukankan      html  css  js  c++  java
  • 测试开发进阶——spring boot——MVC——post访问——通过HttpServletRequest对象获取请求参数

    html中post方式:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
     <form action="http://localhost:8080/test2" method="POST">
         <p>Name <input type = "text" name = "username" /></p>
         <p>password <input type = "text" name = "password" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
    </body>
    </html>
    

      

    控制器:

    package com.awaimai.web;
    
    import org.springframework.web.bind.annotation.*;
    
    import javax.servlet.http.HttpServletRequest;
    
    @RestController
    public class kzq
    {
    
        @RequestMapping(value = "/test2")
        public String test2(HttpServletRequest request)
        {
            String username=request.getParameter("username");
            String password=request.getParameter("password");
            System.out.println("username is:"+username);
            System.out.println("password is:"+password);
            return "success";
    
        }
    
    }
    

      

    web访问:

     

     

  • 相关阅读:
    Spring Boot 应用监控
    学习学习SpringSecurity
    Spring Cloud 简介
    thinkphp 请求
    八、主从复制
    七、AOF 持久化
    五、五大数据类型实现原理
    六、RDB 持久化
    四、redis的底层数据结构
    三、五大数据类型详细用法
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/15086805.html
Copyright © 2011-2022 走看看