public static String computeViewContentType( final HttpServletRequest request, final String defaultContentType, final Charset defaultCharset) { if (request == null) { throw new IllegalArgumentException("Request cannot be null"); } // We will apply the default charset here because, after all, we are in an HTTP environment, and // the way charset is specified in HTTP is as a parameter in the same Content-Type HTTP header. final String combinedContentType = ContentTypeUtils.combineContentTypeAndCharset(defaultContentType, defaultCharset); // Maybe there is no value for 'defaultValue', but anyway we might want to preserve the charset // from the defaultContentType into the viewName-computed one final Charset combinedCharset = ContentTypeUtils.computeCharsetFromContentType(combinedContentType); // If the request path offers clues on the content type that would be more appropriate (because it // ends in ".html", ".xml", ".js", etc.), just use it final String requestPathContentType = ContentTypeUtils.computeContentTypeForRequestPath(request.getRequestURI(), combinedCharset); if (requestPathContentType != null) { return requestPathContentType; } // No way to determine a better/more specific content-type, so just return the (adequately combined) defaults return combinedContentType; }
public static String computeViewContentType( final HttpServletRequest request, final String defaultContentType, final Charset defaultCharset) { if (request == null) { throw new IllegalArgumentException("Request cannot be null"); } // We will apply the default charset here because, after all, we are in an HTTP environment, and // the way charset is specified in HTTP is as a parameter in the same Content-Type HTTP header. final String combinedContentType = ContentTypeUtils.combineContentTypeAndCharset(defaultContentType, defaultCharset); // Maybe there is no value for 'defaultValue', but anyway we might want to preserve the charset // from the defaultContentType into the viewName-computed one final Charset combinedCharset = ContentTypeUtils.computeCharsetFromContentType(combinedContentType); // If the request path offers clues on the content type that would be more appropriate (because it // ends in ".html", ".xml", ".js", etc.), just use it final String requestPathContentType = ContentTypeUtils.computeContentTypeForRequestPath(request.getRequestURI(), combinedCharset); if (requestPathContentType != null) { return requestPathContentType; } // No way to determine a better/more specific content-type, so just return the (adequately combined) defaults return combinedContentType; }
ContentTypeUtils.computeCharsetFromContentType(combinedContentType);
ContentTypeUtils.computeCharsetFromContentType(combinedContentType);
ContentTypeUtils.computeCharsetFromContentType(combinedContentType);