Mohamed Reda Arherbi Mohamed Reda Arherbi - 7 months ago 53
CSS Question

Spring Boot: Adding static content to web application

I'm using Spring Boot and I want to know how exactly we mention the path to static content in my JSP files?
I tried to make them in src/main/resources/static/css but it was not working, and in my JSP I called them by using:

<link href="<c:url value="/css/bootstrap.min.css" />" rel="stylesheet" type="text/css">

I have no special configuration in my SpringBoot Class just the call

Thank you so much for the help!


you have to have configuration that extends WebMvcAutoConfigurationAdapter , it has registry implementation that has automatically scans for some default locations and adds them to classpath

  • /META-INF/resources/
  • /resources/
  • /static/
  • /public/

Just add,

public class ServerConfiguration extends WebMvcAutoConfiguration{