• spring boot——参数传递——POST访问——html网页post提交——@RequestParam获取参数——(@RequestParam("username") String username,@RequestParam("password") String password)


    web网页post提交数据:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
     <form action="http://localhost:8080/test2" method="POST">
         <p>username <input type = "text" name = "username" /></p>
         <p>password <input type = "text" name = "password" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
    </body>
    </html>

      

    控制器:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    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(@RequestParam("username") String username,@RequestParam("password") String password)
        {
            System.out.println("username is:"+username);
            System.out.println("password is:"+password);
            return "success";
     
        }
     
    }

      

    web访问:

     

    ==================================================

    ==================================================

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
     <form action="http://localhost:8080/test289" 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>
    

      

        @RequestMapping(value = "/test289")
        public String test289(@RequestParam("username") String username,@RequestParam("password") String password)
        {
            System.out.println("username is:"+username);
            System.out.println("password is:"+password);
            return "success"+"---                      ---"+username+"---                      ---"+password;
        }
    

      

    ------------------------------------------------------------------------------------------

  • 相关阅读:
    java设计模式演示样例
    一步一步写算法(之排序二叉树)
    收集经常使用的.net开源项目
    jdbc连接数据库
    Android开发系列(二十二):AdapterViewFlipper的功能和使用方法
    ProgressDialog使用总结
    HDU 4916 树分治
    [Unity3D]自制UnityForAndroid二维码扫描插件
    IOS ARC和非ARC文件混用
    让子弹飞Demo版
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/16102516.html
Copyright © 2020-2023  润新知