如何解决可以根据@RequestParam 的值为请求正文设置不同的验证器吗?
是的,我已经看到了 this one。但我的情况与此不同。在那里,场景是否有请求参数。但就我而言,我想根据@RequestParam 的值对@RequestBody 进行不同的验证。这能实现吗?
@PostMapping("/supplier")
@ApiOperation(value = "Get local attributes of a supplier(s)",notes = "Returns the sms attributes of supplier",response = LocalDTO.class)
public @ResponseBody
ResponseEntity<ResponseDTO> getSmsForShippingPoint(
@ApiParam(value = "Search By",required = true) @RequestParam(name = "searchBy") String searchBy,@ApiParam(value = "Suvc,Suffix,Site and Smsvendor",required = true) @RequestBody @Valid RequestSmsDTO requestSmsDTO) throws ValidationException {
if(searchBy.equals("shipping-point")){
ResponseDTO smsResponseDTO = supplierService.findSmsByShippingPoint(requestSmsDTO);
return ResponseEntity.status(HttpStatus.OK)
.body(smsResponseDTO);
}
return null;
}
因此根据 searchBy
的值,我需要对 requestBody 进行不同的验证。就我而言,RequestSmsDTO
对象。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。