不灭的焱

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2022-08-11 10:37:47  修改时间:2023-01-31 08:21:52  分类:Java框架/系统  编辑

一、使用@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