How to specify mime-mapping using servlet 3.0 java config?

I faced this problem in a Spring Boot application. My solution was to create a class that implements org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer as following:

@Configuration
public class MyMimeMapper implements EmbeddedServletContainerCustomizer {
  @Override
  public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    mappings.add("xsd", "text/xml; charset=utf-8");
    container.setMimeMappings(mappings);
  }
}

Just write a Filter. e.g. for mime-mapping in web.xml:

<mime-mapping>
    <extension>mht</extension>
    <mime-type>message/rfc822</mime-type>
</mime-mapping>

We can write a Filter instead:

@WebFilter("*.mht")
public class Rfc822Filter implements Filter {

    public void doFilter(ServletRequest req, ServletResponse resp,
            FilterChain chain) throws IOException, ServletException {
        resp.setContentType("message/rfc822");
        chain.doFilter(req, resp);
    }

    ...
}