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里面创建以之对映的属性 属性名要和传来的参数名保持一致