Polishing (backported from 5.2.x)

This commit is contained in:
Juergen Hoeller
2020-08-07 14:51:08 +02:00
parent ce4001dd40
commit bfd20da9de
11 changed files with 77 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -85,7 +85,6 @@ public class MediaType extends MimeType implements Serializable {
/**
* Public constant media type for {@code application/json}.
* @see #APPLICATION_JSON_UTF8
*/
public static final MediaType APPLICATION_JSON;
@@ -97,7 +96,6 @@ public class MediaType extends MimeType implements Serializable {
/**
* Public constant media type for {@code application/json;charset=UTF-8}.
*
* <p>This {@link MediaType#APPLICATION_JSON} variant should be used to set JSON
* content type because while
* <a href="https://tools.ietf.org/html/rfc7159#section-11">RFC7159</a>
@@ -108,7 +106,6 @@ public class MediaType extends MimeType implements Serializable {
/**
* A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}.
*
* <p>This {@link MediaType#APPLICATION_JSON_VALUE} variant should be used to set JSON
* content type because while
* <a href="https://tools.ietf.org/html/rfc7159#section-11">RFC7159</a>
@@ -407,7 +404,7 @@ public class MediaType extends MimeType implements Serializable {
/**
* Copy-constructor that copies the type and subtype of the given {@code MediaType},
* and allows for different parameter.
* and allows for different parameters.
* @param other the other media type
* @param parameters the parameters, may be {@code null}
* @throws IllegalArgumentException if any of the parameters contain illegal characters
@@ -454,7 +451,7 @@ public class MediaType extends MimeType implements Serializable {
* <p>For instance, {@code text/*} includes {@code text/plain} and {@code text/html},
* and {@code application/*+xml} includes {@code application/soap+xml}, etc.
* This method is <b>not</b> symmetric.
* <p>Simply calls {@link #includes(MimeType)} but declared with a
* <p>Simply calls {@link MimeType#includes(MimeType)} but declared with a
* {@code MediaType} parameter for binary backwards compatibility.
* @param other the reference media type with which to compare
* @return {@code true} if this media type includes the given media type;
@@ -469,7 +466,7 @@ public class MediaType extends MimeType implements Serializable {
* <p>For instance, {@code text/*} is compatible with {@code text/plain},
* {@code text/html}, and vice versa. In effect, this method is similar to
* {@link #includes}, except that it <b>is</b> symmetric.
* <p>Simply calls {@link #isCompatibleWith(MimeType)} but declared with a
* <p>Simply calls {@link MimeType#isCompatibleWith(MimeType)} but declared with a
* {@code MediaType} parameter for binary backwards compatibility.
* @param other the reference media type with which to compare
* @return {@code true} if this media type is compatible with the given media type;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
@@ -64,7 +64,7 @@ public class WebExchangeDataBinder extends WebDataBinder {
/**
* Bind query params, form data, and or multipart form data to the binder target.
* @param exchange the current exchange.
* @param exchange the current exchange
* @return a {@code Mono<Void>} when binding is complete
*/
public Mono<Void> bind(ServerWebExchange exchange) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@@ -101,7 +101,7 @@ public class WebRequestDataBinder extends WebDataBinder {
* <p>The type of the target property for a multipart file can be Part, MultipartFile,
* byte[], or String. The latter two receive the contents of the uploaded file;
* all metadata like original file name, content type, etc are lost in those cases.
* @param request request with parameters to bind (can be multipart)
* @param request the request with parameters to bind (can be multipart)
* @see org.springframework.web.multipart.MultipartRequest
* @see org.springframework.web.multipart.MultipartFile
* @see javax.servlet.http.Part
@@ -109,12 +109,12 @@ public class WebRequestDataBinder extends WebDataBinder {
*/
public void bind(WebRequest request) {
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
if (isMultipartRequest(request) && request instanceof NativeWebRequest) {
if (request instanceof NativeWebRequest) {
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
if (multipartRequest != null) {
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
}
else {
else if (isMultipartRequest(request)) {
HttpServletRequest servletRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class);
if (servletRequest != null) {
bindParts(servletRequest, mpvs);
@@ -126,11 +126,11 @@ public class WebRequestDataBinder extends WebDataBinder {
/**
* Check if the request is a multipart request (by checking its Content-Type header).
* @param request request with parameters to bind
* @param request the request with parameters to bind
*/
private boolean isMultipartRequest(WebRequest request) {
String contentType = request.getHeader("Content-Type");
return (contentType != null && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
return StringUtils.startsWithIgnoreCase(contentType, "multipart/");
}
private void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {