|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -19,6 +19,9 @@ package org.springframework.web.bind.support; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
|
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.validation.BindException; |
|
|
|
import org.springframework.validation.BindException; |
|
|
|
@ -107,13 +110,15 @@ public class WebRequestDataBinder extends WebDataBinder { |
|
|
|
public void bind(WebRequest request) { |
|
|
|
public void bind(WebRequest request) { |
|
|
|
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap()); |
|
|
|
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap()); |
|
|
|
if (request instanceof NativeWebRequest) { |
|
|
|
if (request instanceof NativeWebRequest) { |
|
|
|
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class); |
|
|
|
NativeWebRequest nativeRequest = (NativeWebRequest) request; |
|
|
|
|
|
|
|
MultipartRequest multipartRequest = nativeRequest.getNativeRequest(MultipartRequest.class); |
|
|
|
if (multipartRequest != null) { |
|
|
|
if (multipartRequest != null) { |
|
|
|
bindMultipart(multipartRequest.getMultiFileMap(), mpvs); |
|
|
|
bindMultipart(multipartRequest.getMultiFileMap(), mpvs); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (StringUtils.startsWithIgnoreCase(request.getHeader("Content-Type"), "multipart/")) { |
|
|
|
else if (StringUtils.startsWithIgnoreCase( |
|
|
|
HttpServletRequest servletRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class); |
|
|
|
request.getHeader(HttpHeaders.CONTENT_TYPE), MediaType.MULTIPART_FORM_DATA_VALUE)) { |
|
|
|
if (servletRequest != null) { |
|
|
|
HttpServletRequest servletRequest = nativeRequest.getNativeRequest(HttpServletRequest.class); |
|
|
|
|
|
|
|
if (servletRequest != null && HttpMethod.POST.matches(servletRequest.getMethod())) { |
|
|
|
StandardServletPartUtils.bindParts(servletRequest, mpvs, isBindEmptyMultipartFiles()); |
|
|
|
StandardServletPartUtils.bindParts(servletRequest, mpvs, isBindEmptyMultipartFiles()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|