Mohamed Reda Arherbi Mohamed Reda Arherbi - 1 year ago 110
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!

Answer Source

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{
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download