Spring does not serve static files with unknown extensions

I use tag <mvc:resources .../> to map static content. Everything works fine until I try to access a file with an unknown file extension, for example, some * .less file. When I try to access a file with this extension, I get 404 error. If I change the file extension, for example. * .css, it works great. If I don't use <mvc:resources .../> and map the default servlet to static content, there is no problem either.

Do you know how to fix this? Thanks in advance.

+4
source share
1 answer

Do you use Tomcat? If so, try adding the mime-mapping element to web.xml :

 <mime-mapping> <extension>less</extension> <mime-type>text/plain</mime-type> <!-- Or whatever. --> </mime-mapping> 
+2
source

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


All Articles