SpringBoot request processing-the use of common parameter annotations

1. Common parameters and basic notes

1.1. Notes:

AthPathVariable

@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>

Example:

Detailed lecture notes: https://www.yuque.com/atguigu/springboot/vgzmgh

Lei Fengyang 2021 version of SpringBoot2 zero-based entry springboot full set of full version (spring boot2)

 

 

Guess you like

Origin blog.csdn.net/qq_30398499/article/details/113792690