标签:int 直接 ping json 处理 vat header 定义 object
//region 1.0 接收 Form 表单数据
/**
* Post:PostMapping 传 Body 参数 form-data
* */
@PostMapping(value = "/book/h11")
public String addHeader(@RequestParam("name") String name,@RequestParam("author") String author) {
return "formdata - | " + name + author ;
}
/**
* Post: PostMapping 传 Body 参数 form-data(隐藏 dynamic)
*/
@PostMapping(value = "/book/post/mapparam")
public String addHeader(@RequestParam Map<String, Object> map) {
return "formdata - | dynamic- " + map.get("name") +"|*|"+ map.get("author") ;
}
/**
* Post: PostMapping 传 Body 参数 form-data(隐藏 dynamic)| 参数是 数组
*/
@PostMapping(value = "/book/post/listparam")
public String addHeader(@RequestParam String[] names) {
return Arrays.toString(names);
}
/**
* Post: PostMapping 传 Body 参数 form-data(隐藏 dynamic)| 参数是 实体类
*/
@PostMapping(value = "/book/post/formdataclass")
public String addHeaderformdata(User useraa) {
return "formdata-class |"+useraa.getAccount();
}
//endregion
//region 2.0 接收 JSON 数据
/**
* 传参数 一个类( Body) --注意 是 RequestMapping
* */
@RequestMapping(method = RequestMethod.POST, value = "/book/h5")
public String addHeader(@RequestBody User useraa) {
return "Post" + useraa.getGener() ;
}
//endregion
//region 3.0 特殊处理的 JSON 数据 RequestMapping 可以直接接收单个参数的【@RequestPostSingleParam 自定义注解类{private}】
//@RequestMapping(method = RequestMethod.POST, value = "/book/sd")
@RequestMapping(method = RequestMethod.POST,value = "/book/post/postjson")
public Integer addJsomn(@RequestPostSingleParam Integer id) {
return id ;
}
//endregion
标签:int 直接 ping json 处理 vat header 定义 object
原文地址:https://www.cnblogs.com/wusirAaron/p/14933375.html