Add required flag to @RequestBody
If true and there is no body => HttpMessageNotReadableException If false and there is no body, the argument resolves to null. Issue: SPR-9239
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -44,4 +44,12 @@ import org.springframework.http.converter.HttpMessageConverter;
|
||||
@Documented
|
||||
public @interface RequestBody {
|
||||
|
||||
/**
|
||||
* Whether body content is required.
|
||||
* <p>Default is <code>true</code>, leading to an exception thrown in case
|
||||
* there is no body content. Switch this to <code>false</code> if you prefer
|
||||
* <code>null</value> to be passed when the body content is <code>null</code>.
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user