springMVC接受前端ajax传递的数组

前端jsp代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




Insert title here


	
id: username: age: email:

后端controller代码:

@Controller
@RequestMapping("/user")
public class UserController {
	//List接受数组元素为json对象,@RequestBody注解
	@RequestMapping(value="/addUsers",consumes="application/json;charset=utf-8")
	public String addUser(@RequestBody List users) {
		
		System.out.println(users.size());
		return "succes";
		
	}
}

 

你可能感兴趣的:(java,springMVC,传递参数)