SpringBootリクエスト処理-一般的なパラメータアノテーションの使用

1.一般的なパラメータと基本的な注意事項

1.1。注:

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

<ahref = "/ demo / car / 3 / owner / lisi?age = 11&inters = ball&inters = game&">テスト</a>

例:

詳細な講義ノート:https//www.yuque.com/atguigu/springboot/vgzmgh

SpringBoot2のLeiFengyang 2021バージョンゼロベースのエントリspringbootフルバージョンのフルセット(spring boot2)

 

 

おすすめ

転載: blog.csdn.net/qq_30398499/article/details/113792690