|
|
|
|
@ -55,10 +55,8 @@ import org.springframework.util.Assert;
@@ -55,10 +55,8 @@ import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
|
import org.springframework.validation.BindException; |
|
|
|
|
import org.springframework.validation.BindingResult; |
|
|
|
|
import org.springframework.web.HttpMediaTypeNotSupportedException; |
|
|
|
|
import org.springframework.web.accept.ApiVersionStrategy; |
|
|
|
|
import org.springframework.web.bind.ServletRequestDataBinder; |
|
|
|
|
import org.springframework.web.bind.WebDataBinder; |
|
|
|
|
import org.springframework.web.util.UriBuilder; |
|
|
|
|
import org.springframework.web.util.UriComponentsBuilder; |
|
|
|
|
@ -343,32 +341,8 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@@ -343,32 +341,8 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public <T> T bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) throws BindException { |
|
|
|
|
Assert.notNull(bindType, "BindType must not be null"); |
|
|
|
|
Assert.notNull(dataBinderCustomizer, "DataBinderCustomizer must not be null"); |
|
|
|
|
|
|
|
|
|
ServletRequestDataBinder dataBinder = new ServletRequestDataBinder(null); |
|
|
|
|
dataBinder.setTargetType(ResolvableType.forClass(bindType)); |
|
|
|
|
dataBinderCustomizer.accept(dataBinder); |
|
|
|
|
|
|
|
|
|
HttpServletRequest servletRequest = servletRequest(); |
|
|
|
|
dataBinder.construct(servletRequest); |
|
|
|
|
dataBinder.bind(servletRequest); |
|
|
|
|
|
|
|
|
|
BindingResult bindingResult = dataBinder.getBindingResult(); |
|
|
|
|
if (bindingResult.hasErrors()) { |
|
|
|
|
throw new BindException(bindingResult); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
T result = (T) bindingResult.getTarget(); |
|
|
|
|
if (result != null) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
throw new IllegalStateException("Binding result has neither target nor errors"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return DefaultServerRequest.doBind(bindType, dataBinderCustomizer, servletRequest()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|