好的,我自己找到的:-)
在Spring boot中,您可以使用此定制器定制servlet容器,并在其中添加新的mimetypes。
( 更新 )
spring启动2.x:
@Componentpublic class ServletCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> { @Override public void customize(TomcatServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("woff", "application/x-font-woff"); factory.setMimeMappings(mappings); }}spring启动1.x:
@Componentpublic class ServletCustomizer implements EmbeddedServletContainerCustomizer { @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("woff","application/font-woff"); mappings.add("woff2","application/font-woff2"); container.setMimeMappings(mappings); }}


