How to handle static content in Spring MVC?

前端 未结 23 2848
春和景丽
春和景丽 2020-11-22 03:28

I am developing a webapp using Spring MVC 3 and have the DispatcherServlet catching all requests to \'/\' like so (web.xml):

  
          


        
23条回答
  •  悲哀的现实
    2020-11-22 04:09

    If I understand your issue correctly, I think I have found a solution to your problem:

    I had the same issue where raw output was shown with no css styles, javascripts or jquery files found.

    I just added mappings to the "default" servlet. The following was added to the web.xml file:

     
      default
      *.css
     
    
     
        default
        *.js
     
    

    This should filter out the javascript and css file requests from the DispatcherRequest object.

    Again, not sure if this is what you are after, but it worked for me. I think "default" is the name of the default servlet within JBoss. Not too sure what it is for other servers.

提交回复
热议问题