Polishing

This commit is contained in:
Juergen Hoeller
2020-08-07 15:15:40 +02:00
parent 17a47b30e9
commit cc1f0e1186
7 changed files with 62 additions and 57 deletions

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.
@@ -82,7 +82,6 @@ public class MediaType extends MimeType implements Serializable {
/**
* Public constant media type for {@code application/json}.
* @see #APPLICATION_JSON_UTF8
*/
public final static MediaType APPLICATION_JSON;
@@ -334,7 +333,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
@@ -381,7 +380,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;
@@ -396,7 +395,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;
@@ -470,7 +469,7 @@ public class MediaType extends MimeType implements Serializable {
}
/**
* Parse the given comma-separated string into a list of {@code MediaType} objects.
* Parse the comma-separated string into a list of {@code MediaType} objects.
* <p>This method can be used to parse an Accept or Content-Type header.
* @param mediaTypes the string to parse
* @return the list of media types

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -106,7 +106,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
@@ -114,12 +114,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 if (servlet3Parts) {
else if (servlet3Parts && isMultipartRequest(request)) {
HttpServletRequest serlvetRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class);
new Servlet3MultipartHelper(isBindEmptyMultipartFiles()).bindParts(serlvetRequest, mpvs);
}
@@ -129,11 +129,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/");
}
/**