Where do CSS and JavaScript files go in a Maven web app project?

So if you have your DispatcherServlet configured in a REST like URL pattern such as / then css files would go under src/main/webapp/resources

Just to clarify this is what I had to do:

  1. Make sure that in your servlet-context.xml you have as follows:

    <resources mapping="/resources/**" location="/resources/" /> 
    
  2. Create a folder if does not already exist under webapps called resources

  3. Place your css folder along with css files there

  4. Reference my css file as follows:

    <link rel="stylesheet" href="https://stackoverflow.com/questions/7836930/<%=request.getContextPath()%>/resources/css/960.css"/>
    

Leave a Comment