一、使用@RequestParam
@RequestMapping(value = "/login", method = RequestMethod.POST) public Map<String, Object> login(@RequestParam("username") String username, @RequestParam("password") String password) { Map<String, Object> map = new HashMap<>(); log.info("正在登录,账号 = {},密码 = {}", username, password); return map; }
二、使用Map
@RequestMapping(value = "/login", method = RequestMethod.POST) public Map<String, Object> login(@RequestParam Map<String,Object> params) { Map<String, Object> map = new HashMap<>(); log.info("正在登录,账号 = {},密码 = {}", params.get("username"), params.get("password")); return map; }
三、使用数组
@RequestMapping(value = "/login", method = RequestMethod.POST) public void login(@RequestParam("name") String[] names) { for(String name: names) { System.out.println(name); } }
四、使用自定义对象
(略)
参考:/2297.html