美文网首页
SpringBoot请求接受

SpringBoot请求接受

作者: 朴炯文 | 来源:发表于2019-11-24 17:37 被阅读0次

    get

    @PathVariable
    获取路径参数。即url/{id}这种形式。
    @RequestParam
    获取查询参数。即url?name=这种形式

    @GetMapping("/demo/{id}")
    public void demo(@PathVariable(name = "id") String id, @RequestParam(name = "name") String name) {
        System.out.println("id="+id);
        System.out.println("name="+name);
    }
    

    post

    vue

    let obj = {};
    obj['xxx'] =xxx;
    axios.post(url, obj).then(response => {
      xxx
    });
    

    @RequestBody

    @PostMapping(path = "/demo1")
    public void demo1(@RequestBody Person person) {
        System.out.println(person.toString());
    }
    //或者
    @PostMapping(path = "/demo1")
    public void demo1(@RequestBody Map<String, String> person) {
        System.out.println(person.get("name"));
    }
    

    相关文章

      网友评论

          本文标题:SpringBoot请求接受

          本文链接:https://www.haomeiwen.com/subject/jvzkwctx.html