How to access static resources when mapping a global front controller servlet on /*

前端 未结 19 2143
轮回少年
轮回少年 2020-11-22 07:35

I\'ve mapped the Spring MVC dispatcher as a global front controller servlet on /*.

               


        
相关标签:
19条回答
  • 2020-11-22 08:25

    I found a simpler solution with a dummy index file.

    Create a Servlet (or use the one you wanted to respond to "/") which maps to "/index.html" (Solutions mentioned here use the mapping via XML, I used the 3.0 version with annotation @WebServlet) Then create a static (empty) file at the root of the static content named "index.html"

    I was using Jetty, and what happened was that the server recognized the file instead of listing the directory but when asked for the resource, my Servlet took control instead. All other static content remained unaffected.

    0 讨论(0)
提交回复
热议问题