Spring can't load my css files

后端 未结 2 469
遥遥无期
遥遥无期 2021-01-14 23:12

Spring can\'t load my css files and this is my architecture:

  • Project
    • Webcontent
    • WEB-INF
      • pages
        • index.jsp
2条回答
  •  一生所求
    2021-01-14 23:48

    As fvu explained, the content inside WEB-INF is not accessible over HTTP. The Webcontent directory in your directory structure looks like it was created for this particular purpose: storing CSS files, images and JavaScript files.

    Even after you move your CSS files, they will not be accessible over HTTP automatically because Spring MVC will intercept these HTTP requests. You need to use the tag in your bean configuration:

    Your CSS files will be accessible at URLs like the following:

    http://localhost:8080/you-app-name/webcontent/...

    There is a lot of information on at Stackoverflow.

提交回复
热议问题