Hello, I just can not connect the CSS file to the JSP page. I tried many different types of links in the head, I tried using the jstl / core library. The file stupidly does not pull up. Abstract is present. Attached the project structure. What needs to be changed in the annotation or in JSP correctly set the path to the CSS file.

<mvc:resources mapping="/resources/**" location="/resources/" /> 

enter image description here

  • 2
    There is no need to change anything in the annotation, your CSS file is not there. It should be in src/webapp/resources . In JSP, be sure to specify the link in the context context path. - enzo
  • Earned, thanks. Strange but for some reason Maven project does just such a directory structure. - Yurii
  • one
    Maven creates everything correctly. The src/main/resources directory usually stores configuration files and resources that later fall into the application classpath. These are the authors of the documentation or educational articles. I don’t know why they called the folder where the static resources are also stored - resources , which confuses newbies - you are not the first. Reassign it to static or assets so as not to be confused. - enzo
  • Thanks for the advice, renamed to static. Can you please look at my other question? Link - goo.gl/ScebPJ - Yurii

1 answer 1

I had the same problem ... Decided to add

 <mvc:annotation-driven/> 

I also specified the caching period for the browser ... But it comes to different browsers in different ways: it immediately reached FF and in 10 minutes chrome.

 <mvc:resources mapping="/resources/**" location="/resources/" cache-period="10"/> 

Also changed the configuration:

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">