Clean up content type in ContentNegotiatingViewResolver

This commit removes the quality value of the selected media type before
setting it in the request attribute.

Closes gh-26315
This commit is contained in:
Arjen Poutsma
2021-01-14 14:30:07 +01:00
parent 469eb8146e
commit d1a7fed16c
2 changed files with 23 additions and 0 deletions

View File

@@ -344,6 +344,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
if (StringUtils.hasText(candidateView.getContentType())) {
MediaType candidateContentType = MediaType.parseMediaType(candidateView.getContentType());
if (mediaType.isCompatibleWith(candidateContentType)) {
mediaType = mediaType.removeQualityValue();
if (logger.isDebugEnabled()) {
logger.debug("Selected '" + mediaType + "' given " + requestedMediaTypes);
}