Why does Jetty serve css as a text / html MIME type in a maven-plugin

I tried the following configuration:

<plugin>
            <groupId>org.mortbay.jetty</groupId>  
            <artifactId>jetty-maven-plugin</artifactId>
            <version>7.6.14.v20131031</version>
            <!--  
            <version>7.6.14.v20131031</version>
            <version>8.1.10.v20130312</version>
            -->     
            <configuration>
                <reload>manual</reload>
                <webApp>
                    <contextPath>/myapp</contextPath>
                    <defaultsDescriptor>${basedir}/src/test/resources/jetty/webdefault.xml</defaultsDescriptor>
                    <jettyEnvXml>${basedir}/src/test/resources/jetty/jetty-env.xml</jettyEnvXml>
                    <descriptor>${basedir}/src/test/resources/jetty/web.xml</descriptor>
                </webApp>
                <webAppSourceDirectory>${basedir}/WebContent</webAppSourceDirectory>
            </configuration>
    </plugin>

But the answer always has the wrong MIME type, like text / html, and not the expected text / css:

Server: Jetty(7.6.14.v20131031)
Last-Modified:  Thu, 16 Jan 2014 08:09:48 GMT
Content-Type:   text/html;charset=UTF-8
Content-Length: 28095
Content-Language:   en-US
Accept-Ranges:  bytes

I extracted the webdefault.xml file and added it below:

<mime-mapping>
  <extension>css</extension>
  <mime-type>text/css</mime-type>
</mime-mapping>

And I also tried adding the code snippet above to my web.xml, but still no luck.

What should I do then? Please advise, thanks.

+4
source share

Source: https://habr.com/ru/post/1547373/


All Articles