@PostMapping("/sponsor")
@ApiOperation("发起")
public JSONResponse sponsor(@ApiParam(value = "传参") @RequestBody SponsorInsertContractRequest request) {
原因:因为参数为空或null。
解决方案:1、查看前端是否传参正确
2、如果前端没有问题,则修改RequestBody注解的required属性。!parameter.isOptional()代表是否支持null,如果参数类型支持null,则是false,最终不用校验required.
public @interface RequestBody {
/**
* Whether body content is required.
* <p>Default is {@code true}, leading to an exception thrown in case
* there is no body content. Switch this to {@code false} if you prefer
* {@code null} to be passed when the body content is {@code null}.
* @since 3.2
*/
boolean required() default true;
}
默认是true.我们只需要@RequestBody (required=false)