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

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

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

               


        
19条回答
  •  长情又很酷
    2020-11-22 08:05

    What you do is add a welcome file in your web.xml

    
        index.html
    
    

    And then add this to your servlet mappings so that when someone goes to the root of your application, they get sent to index.html internally and then the mapping will internally send them to the servlet you map it to

    
        MainActions
        /main
    
    
        MainActions
        /index.html
    
    

    End result: You visit /Application, but you are presented with /Application/MainActions servlet without disrupting any other root requests.

    Get it? So your app still sits at a sub url, but automatically gets presented when the user goes to the root of your site. This allows you to have the /images/bob.img still go to the regular place, but '/' is your app.

提交回复
热议问题