zoukankan      html  css  js  c++  java
  • string boot中get、post 接口

    后端接口:

    1.get,调用方式 http://127.0.0.1:8088/xxxx/{id}

    代码如下:

    1 /**
    2      * get方式
    3      */
    4     @RequestMapping(value = "/xxxxx/{id}", method = RequestMethod.GET)
    5     public Object xxxxx(@PathVariable int id) {
    6         //以下是逻辑处理
    7 
    8         return xxx;
    9     }
    View Code

    2.post

    1)调用地址 http://127.0.0.1:8088/xxxx ,入参格式 application/json,{"a":111,"b":"aa"}

     代码如下:

     1 /**
     2      * post方式
     3      */
     4     @RequestMapping(value = "/xxxxx", method = RequestMethod.POST)
     5     public Object xxxxx(@RequestBody HashMap<String, String> map)
     6     {
     7         System.out.println("map:"+map);
     8 
     9         //以下是逻辑处理
    10         
    11 
    12         return xxxx;
    13     }
    View Code

    2)调用地址 http://127.0.0.1:8088/xxxx ,入参格式 application/form-data 格式 :phone: "18295880001", env: "dev"

     代码如下:

     1 /**
     2      * post方式
     3      */
     4     @RequestMapping(value = "/xxxxx", method = RequestMethod.POST)
     5     public Object xxxxx(@RequestParam(value = "xxx", required = true) String xxx,
     6         @RequestParam(value = "env", required = xxx) String xxx)
     7     {
     8         //以下是逻辑处理
     9 
    10         return xxxxx;
    11     }
    View Code
  • 相关阅读:
    个人总结---小水长流,则能穿石
    软件工程与UML作业3(互评作业)
    软件工程与UML作业2
    软件工程与UML作业1
    大创省级答辩总结
    C语言知识汇编
    C语言知识点汇集
    C语言汇总3
    C语言汇总2
    c语言汇总1
  • 原文地址:https://www.cnblogs.com/whycai/p/14090375.html
Copyright © 2011-2022 走看看