@Override public void customize(TomcatServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); factory.setMimeMappings(mappings ); }
@Override public Iterator<Mapping> iterator() { return getAll().iterator(); }
@Override public void setMimeMappings(MimeMappings mimeMappings) { this.mimeMappings = new MimeMappings(mimeMappings); }
/** * Get the content type corresponding to an extension. * @param extension the extension to search the content type for * @return the content type */ public static Optional<String> getContentTypeByExtension(String extension) { return Optional.ofNullable(DEFAULT.get(extension)); }
/** * Create a new unmodifiable view of the specified mapping. Methods that attempt to * modify the returned map will throw {@link UnsupportedOperationException}s. * @param mappings the mappings * @return an unmodifiable view of the specified mappings. */ public static MimeMappings unmodifiableMappings(MimeMappings mappings) { return new MimeMappings(mappings, false); }
@Override public void customize(ConfigurableServletWebServerFactory factory) { MimeMappings mimeMappings = new MimeMappings(MimeMappings.DEFAULT); mimeMappings.add("yaml", "text/vnd.yaml"); factory.setMimeMappings(mimeMappings); }
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("hbs", "text/x-handlebars-template"); mappings.add("hal", "application/hal+json"); factory.setMimeMappings(mappings); return factory; }
@Bean public ConfigurableServletWebServerFactory webServerFactory() { final TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); final Set<ErrorPage> errorPages = new HashSet<>(); errorPages.add(new ErrorPage(HttpStatus.NOT_FOUND, "/web/error/404")); factory.setErrorPages(errorPages); final MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("xsd", "text/xml; charset=utf-8"); mappings.add("ico", "image/x-icon"); factory.setMimeMappings(mappings); return factory; }
@Bean public ConfigurableServletWebServerFactory webServerFactory() { final JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); final Set<ErrorPage> errorPages = new HashSet<>(); errorPages.add(new ErrorPage(HttpStatus.NOT_FOUND, "/web/error/404")); factory.setErrorPages(errorPages); final MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("xsd", "text/xml; charset=utf-8"); mappings.add("ico", "image/x-icon"); factory.setMimeMappings(mappings); return factory; } }