SpringBoot请求处理-常用参数注解使用

1、普通参数与基本注解

1.1、注解:

@PathVariable

@RequestHeader

@ModelAttribute

@RequestParam

@MatrixVariable

@CookieValue

@RequestBody

@GetMapping("/car/{id}/owner/{username}")
@ResponseBody
public Map<String, Object> getCar(@PathVariable("id") String id,
                         @PathVariable("username") String username,
                         @PathVariable Map<String, Object> pv,
                         @RequestHeader("User-Agent") String agent,
                         @RequestHeader Map<String, Object> header,
                         @RequestParam("age") Integer age,
                         @RequestParam("inters") List<String> inters,
                         @RequestParam Map<String, Object> params) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", username);
        map.put("pv", pv);
        map.put("agent", agent);
        map.put("header", header);
        map.put("age", age);
        map.put("inters", inters);
        map.put("params", params);
        return map;
}

html

<a href="/demo/car/3/owner/lisi?age=11&inters=ball&inters=game&">test</a>

示例:

详细讲义:https://www.yuque.com/atguigu/springboot/vgzmgh

雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)

猜你喜欢

转载自blog.csdn.net/qq_30398499/article/details/113792690