/** * Determine the media type for the given request and the resource matched * to it. This implementation tries to determine the MediaType based on the * file extension of the Resource via * {@link ServletPathExtensionContentNegotiationStrategy#getMediaTypeForResource}. * @param request the current request * @param resource the resource to check * @return the corresponding media type, or {@code null} if none found */ @Nullable protected MediaType getMediaType(HttpServletRequest request, Resource resource) { return (this.contentNegotiationStrategy != null ? this.contentNegotiationStrategy.getMediaTypeForResource(resource) : null); }
/** * Determine the media type for the given request and the resource matched * to it. This implementation tries to determine the MediaType based on the * file extension of the Resource via * {@link ServletPathExtensionContentNegotiationStrategy#getMediaTypeForResource}. * @param request the current request * @param resource the resource to check * @return the corresponding media type, or {@code null} if none found */ @Nullable protected MediaType getMediaType(HttpServletRequest request, Resource resource) { return (this.contentNegotiationStrategy != null ? this.contentNegotiationStrategy.getMediaTypeForResource(resource) : null); }
/** * Extends the base class * {@link PathExtensionContentNegotiationStrategy#getMediaTypeForResource} * with the ability to also look up through the ServletContext. * @param resource the resource to look up * @return the MediaType for the extension, or {@code null} if none found * @since 4.3 */ @Override public MediaType getMediaTypeForResource(Resource resource) { MediaType mediaType = null; String mimeType = this.servletContext.getMimeType(resource.getFilename()); if (StringUtils.hasText(mimeType)) { mediaType = MediaType.parseMediaType(mimeType); } if (mediaType == null || MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) { MediaType superMediaType = super.getMediaTypeForResource(resource); if (superMediaType != null) { mediaType = superMediaType; } } return mediaType; }
/** * Extends the base class * {@link PathExtensionContentNegotiationStrategy#getMediaTypeForResource} * with the ability to also look up through the ServletContext. * @param resource the resource to look up * @return the MediaType for the extension, or {@code null} if none found * @since 4.3 */ @Override public MediaType getMediaTypeForResource(Resource resource) { MediaType mediaType = null; String mimeType = this.servletContext.getMimeType(resource.getFilename()); if (StringUtils.hasText(mimeType)) { mediaType = MediaType.parseMediaType(mimeType); } if (mediaType == null || MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) { MediaType superMediaType = super.getMediaTypeForResource(resource); if (superMediaType != null) { mediaType = superMediaType; } } return mediaType; }
/** * Determine an appropriate media type for the given resource. * @param resource the resource to check * @return the corresponding media type, or {@code null} if none found * @deprecated as of 4.3 this method is deprecated; please override * {@link #getMediaType(HttpServletRequest, Resource)} instead. */ @Deprecated protected MediaType getMediaType(Resource resource) { return null; }
/** * Extends the base class * {@link PathExtensionContentNegotiationStrategy#getMediaTypeForResource} * with the ability to also look up through the ServletContext. * @param resource the resource to look up * @return the MediaType for the extension, or {@code null} if none found * @since 4.3 */ @Override public MediaType getMediaTypeForResource(Resource resource) { MediaType mediaType = null; String mimeType = this.servletContext.getMimeType(resource.getFilename()); if (StringUtils.hasText(mimeType)) { mediaType = MediaType.parseMediaType(mimeType); } if (mediaType == null || MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) { MediaType superMediaType = super.getMediaTypeForResource(resource); if (superMediaType != null) { mediaType = superMediaType; } } return mediaType; }
/** * Extends the base class * {@link PathExtensionContentNegotiationStrategy#getMediaTypeForResource} * with the ability to also look up through the ServletContext. * @param resource the resource to look up * @return the MediaType for the extension, or {@code null} if none found * @since 4.3 */ @Override public MediaType getMediaTypeForResource(Resource resource) { MediaType mediaType = null; String mimeType = this.servletContext.getMimeType(resource.getFilename()); if (StringUtils.hasText(mimeType)) { mediaType = MediaType.parseMediaType(mimeType); } if (mediaType == null || MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) { MediaType superMediaType = super.getMediaTypeForResource(resource); if (superMediaType != null) { mediaType = superMediaType; } } return mediaType; }