@Postmapping 使用 json 传输参数list (两种方法接收)

PostMan 参数如图:


@RestController
@RequestMapping("/sys/mytest")
public class SysMytestController extends BaseController { 
//方法1
    @PostMapping("/save1")public Result save(@Validated  @RequestBody  Map<String,Object>   mapList) { 
        String v1=mapList.get("v1").toString();
        String v2=mapList.get("v2").toString();
        return Result.succ("");
    }
//方法2 
   @PostMapping("/save2")
    public Result save1(@RequestBody JSONObject params ) { 
        String v1 = params.get("v1").toString();
        String v2 = params.get("v2").toString();
        return Result.succ("");    }

 

posted @ 2022-01-12 20:22  Janus2003  阅读(7859)  评论(1编辑  收藏  举报