Spring not finding resource files (css, jsp…)

前端 未结 2 492
傲寒
傲寒 2020-12-16 07:16

I\'m using a jsp file as a model from a Controller and I want to use an css styles and js libraries

  • Proyect
    • Webcontent
    • assets
    • WEB-IN
2条回答
  •  攒了一身酷
    2020-12-16 08:01

    The problem is that your requests for CSS and JS files are going through Dispatcher Servlet, which is not correct. Hence Spring won't find the mapping for those files it will not load them.

    You need to add the resourceHandler for your application in the applicationContext.xml file as follows. This configuration will bypass the requests for CSS and JS files from the Dispatcher Servlet.

    
    

    Hope this helps you... Cheers.

    Please put following code in web.xml

    
      default
      *.css
     
    
     
        default
        *.js
     
    

提交回复
热议问题