@RequestParam用Map接收参数

原文链接:https://blog.csdn.net/reee112/article/details/89279286   (侵删)

 @RequestParam 注解如果是个map类型,那么mvc适配器就将参数封装到map中

请求地址:localhost:8080/test?name=testname&pwd=123456

@RequestMapping("/test")
    public Object hello2(@RequestParam Map query) {
        String name = (String) query.get("name");
        String pwd = (String) query.get("pwd");
        System.out.println(name);
        System.out.println(pwd);
        return query;
    }

返回参数:

{
    "name": "testname",
    "pwd": "123456"
}

猜你喜欢

转载自www.cnblogs.com/cmz-32000/p/12187314.html