Add protected method for required RequestBody
This commit is contained in:
parent
7756feacd8
commit
e4539d9f40
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -146,7 +146,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
|||
|
||||
Object arg = readWithMessageConverters(inputMessage, methodParam, paramType);
|
||||
if (arg == null) {
|
||||
if (methodParam.getParameterAnnotation(RequestBody.class).required()) {
|
||||
if (checkRequired(methodParam)) {
|
||||
throw new HttpMessageNotReadableException("Required request body is missing: " +
|
||||
methodParam.getMethod().toGenericString());
|
||||
}
|
||||
|
@ -154,6 +154,10 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
|||
return arg;
|
||||
}
|
||||
|
||||
protected boolean checkRequired(MethodParameter methodParam) {
|
||||
return methodParam.getParameterAnnotation(RequestBody.class).required();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
|
||||
|
|
Loading…
Reference in New Issue