java之mvc接收postman传递list

接口

 /// 
        /// 测试传入list集合类型的参数
        /// 
        /// 
        /// 
        /// 
        /// 
        public string PostPeoples([FromBody]List ps)
        {
            string str = "";
            foreach (var item in ps)
            {
                str += item.Name + ",";
            }
            return str.Trim(',');
        }

Postman 调用(错误版本)

java之mvc接收postman传递list_第1张图片

 

Postman 调用(正确版本)

java之mvc接收postman传递list_第2张图片

1.注意如果list不是内嵌对象则不需要名称,如果上面的错误示范ps

2.如果是内嵌对象这是需要的。

{"id":671202,"trainName":"test", "trainContent":"content","accessUser":[{"account":"123","name":"zhangsan"},{"account":"345","name":"lisi"}]}  

如下:accessUser

public class SafeTrainReq {
    private String trainName;
    private String trainContent;
    private List accessUser;

 

 

 

 

 

你可能感兴趣的:(java)