@RequestMapping(value = "/unlock", method = RequestMethod.POST)
public ResultDTO<Boolean> unlockCustomer(@RequestHeader("id") String testId,
@RequestBody String requestBody) {
List<Long> customerIdList = JSONObject.parseArray(requestBody, Long.class);
logger.info("解锁客户请求,customerId={}", customerIdList);
logger.info("解锁客户成功!");
return new ResultDTO<Boolean>(true, "解锁客户成功!");
}
@RequestMapping(value = "/unlock", method = RequestMethod.POST)
public ResultDTO<Boolean> unlockCustomer(@RequestHeader("id") String testId,
@RequestBody List<Long> customerIdList) {
logger.info("解锁客户请求,customerId={}", customerIdList);
customerManageService.unlockCustomer(operatorId, operatorName, customerIdList);
return new ResultDTO<Boolean>(true, "解锁客户成功!");
}
使用Postman传json串一直报错,没找到原因。后来使用String类型来接收@RequestBody,并且查看接收到的值之后,才发现是因为传的格式有问题导致使用@RequestBody转换失败。现在上面两种方法都是可行的,第二种比较方便。由于各式问题导致后台接收不到值已经出现两次了,所以先记录下来。