前后端交互传参问题,help~
前端传给后端的数据如下
后端的代码如下
@ApiOperation("添加二级活动")@RequestMapping(value = "/AddEventInFo", method = RequestMethod.POST)
@ResponseBody
public CommonResult AddEventInFo(@RequestParam(required = false) Integer eventId,
@RequestParam(required = false) String eventInfoName,
@RequestParam(required = false) String eventType,
@RequestParam(required = false, value = "eventDate[]") String[] eventDate,
@RequestParam(required = false, value = "beginDate[]") String[] beginDate,
@RequestParam(required = false, value = "reachDate[]") String[] reachDate,
@RequestParam(required = false) String periodFlag,
@RequestParam(required = false) String periodType,
@RequestParam(required = false) String periodFrequency,
@RequestParam(required = false) String referFlag
) throws ParseException {
EventInfo eventInfo = new EventInfo();
eventInfo.setEventId(eventId);
eventInfo.setEventInfoName(eventInfoName);
eventInfo.setEventType(eventType);
eventInfo.setEventStartDate(sdf.parse(eventDate[0]));
eventInfo.setEventEndDate(sdf.parse(eventDate[1]));
eventInfo.setBeginStartDate(sdf.parse(beginDate[0]));
eventInfo.setBeginEndDate(sdf.parse(beginDate[1]));
eventInfo.setReachStartDate(sdf.parse(reachDate[0]));
eventInfo.setReachEndDate(sdf.parse(reachDate[1]));
eventInfo.setPeriodFlag(periodFlag);
eventInfo.setPeriodType(periodType);
eventInfo.setPeriodFrequency(periodFrequency);
eventInfo.setReferFlag(referFlag);
int result = eventService.addEventInfo(eventInfo);
if(result > 0){
return CommonResult.success("添加二级活动成功");
}else {
return CommonResult.failed("添加二级活动失败");
}
}
大佬们啊,帮忙看看
后端现在,除了传的几个日期数组,接收不到,其他参数都能接收到,问题出在哪里呀?请大佬指点
回答:
- 因为你value写错了 不能加[] 去掉括号即可,value对应的是你的参数名
- 这种最好是创建一个param对象最好
以上是 前后端交互传参问题,help~ 的全部内容, 来源链接: utcz.com/p/944128.html