传参方式
package com.zzb.test;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/passparam")
public class PassParam {
/*
http://localhost:8088/passparam/get/1/2 id是1 count是2
路径传参数
* */
@GetMapping("/get/{id}/{count}")
public Map get1(@PathVariable("id") Integer id, @PathVariable("count") Integer count){
Map map = new HashMap();
map.put("id",id);
map.put("count",count);
return map;
}
/*
http://localhost:8088/passparam/get?id=1&count=2 id是1 count是2
变量传参
* */
@GetMapping("/get")
public Map get2(@RequestParam("id") Integer id, @RequestParam("count") Integer count){
Map map = new HashMap();
map.put("id",id);
map.put("count",count);
return map;
}
}
————————————————
版权声明:本文为CSDN博主「静安书以沫」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/whatname123/article/details/115622245