解决Failed to instantiate [java.util.List]: Specified class is an interface问题

错误信息提示

Failed to instantiate [java.util.List]: Specified class is an interface;

前端传递一个数组对象时,后端接收实例化出错

javascript代码

var userIdArr = [1,2,3];
$.ajax({
	url:"/receiveArr",
	type:"POST",
	data:{"userIdArr":userIdArr},
	success:function(rtn){
		alert("OK");
	}
})

Java代码

@RequestMapping(value = "receiveArr", method = RequestMethod.POST)
@ResponesBody
public String receiveArr(@RequestParam(value = "userIdArr") int[] userIds){
	return "";
}

解决办法:

在java方法参数注解@RequestParam中的value值后添加"[ ]",
即:@RequestParam(value = “userIdArr[]”)

你可能感兴趣的:(异常解决)