zoukankan      html  css  js  c++  java
  • postman 多个list入参

    java后台接收

    @RestController
    @RequestMapping("api/ptNotice")
    public class PtNoticeController {
    @RequestMapping("/find")
    PtNoticeVo find(@RequestBody PtNoticeVo ptNoticeVo ){
    System.out.println(ptNoticeVo.getNoticeId());
    ptNoticeVo.getToSendIds().forEach(item->{
    System.out.println(item);
    });
    ptNoticeVo.getToSendUsers().forEach(item->{
    System.out.println(item);
    });
    return ptNoticeVo;
    }
    }

    PtNoticeVo 代码

    package com.huyuqiang.vo.ptNotice;
    
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    
    public class PtNoticeVo implements Iterator<Object> {
    
        private String noticeId;
        private String noticeTitle;
        private String noticeInfo;
    
        private List<String> toSendIds;
    
        public PtNoticeVo() {
        }
    
        public PtNoticeVo(String noticeId, String noticeTitle, String noticeInfo, List<String> toSendIds, List<Map<String, String>> toSendUsers) {
    
            this.noticeId = noticeId;
            this.noticeTitle = noticeTitle;
            this.noticeInfo = noticeInfo;
            this.toSendIds = toSendIds;
            this.toSendUsers = toSendUsers;
        }
    
        private List<Map<String,String>> toSendUsers;
    
        public String getNoticeId() {
            return noticeId;
        }
    
        public void setNoticeId(String noticeId) {
            this.noticeId = noticeId;
        }
    
        public String getNoticeTitle() {
            return noticeTitle;
        }
    
        public void setNoticeTitle(String noticeTitle) {
            this.noticeTitle = noticeTitle;
        }
    
        public String getNoticeInfo() {
            return noticeInfo;
        }
    
        public void setNoticeInfo(String noticeInfo) {
            this.noticeInfo = noticeInfo;
        }
    
        public List<String> getToSendIds() {
            return toSendIds;
        }
    
        public void setToSendIds(List<String> toSendIds) {
            this.toSendIds = toSendIds;
        }
    
        public List<Map<String, String>> getToSendUsers() {
            return toSendUsers;
        }
    
        public void setToSendUsers(List<Map<String, String>> toSendUsers) {
            this.toSendUsers = toSendUsers;
        }
    
        @Override
        public boolean hasNext() {
            return false;
        }
    
        @Override
        public Object next() {
            return null;
        }
    }

     vo当做一个接收前端数据的bean 

    有参无参构造方法 封装 toString 都要有

    前端json 传入的有字符串 string泛型的list map泛型的list 

    在vo里面创建以之对映的属性 属性名要和传来的参数名保持一致

  • 相关阅读:
    servlet的九大内置对象
    java中static、transient修饰的属性不能被序列化
    java 字节流与字符流的区别
    mac 下如何切换jdk的版本
    00 python基础--目录结构
    html 5 本地数据库-- Web Sql Database核心方法openDatabase、transaction、executeSql 详解
    shell脚本入门
    Canvas API详解
    精通CSS滤镜(filter)(实例解析)
    CSS中加号、星号及其他符号的作用
  • 原文地址:https://www.cnblogs.com/woshuyuqiang/p/9741433.html
Copyright © 2011-2022 走看看