Browse Source

Add protected method for required RequestBody

pull/959/head
Rossen Stoyanchev 9 years ago
parent
commit
e4539d9f40
  1. 8
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java

8
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessor.java

@ -1,5 +1,5 @@ @@ -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 @@ -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 @@ -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…
Cancel
Save