接口入参注解@PathVariable与@RequestParam
@RequestParam
@RequestMapping(value = "/test", method = {RequestMethod.POST, RequestMethod.GET})
public String test(@RequestParam("name") String name) {
System.out.println(name);
return name;
}
http://localhost:端口号/test?name=345
@PathVariable
@RequestMapping(value = "/test/{name}", method = {RequestMethod.POST, RequestMethod.GET}) public String test(@PathVariable("name") String name) { System.out.println(name); return name; }
localhost:22499/user/test/zhangsan
两个注解可以组合使用
本文来自博客园,作者:皮军旗,转载请注明原文链接:https://www.cnblogs.com/pijunqi/p/17377170.html