I try to load style from my resources folder (/resources/static/styles.css) but embedded tomcat answers 404.
@Configuration
@EnableWebMvc
public class PugTemplateConfiguration {
@Bean
public SpringTemplateLoader templateLoader() {
SpringTemplateLoader templateLoader
= new SpringTemplateLoader();
templateLoader.setTemplateLoaderPath("classpath:/templates/");
templateLoader.setEncoding("UTF-8");
templateLoader.setSuffix(".pug");
return templateLoader;
}
@Bean
public PugConfiguration pugConfiguration() {
PugConfiguration configuration = new PugConfiguration();
configuration.setCaching(false);
configuration.setTemplateLoader(templateLoader());
return configuration;
}
@Bean
public ViewResolver viewResolver() {
PugViewResolver viewResolver = new PugViewResolver();
viewResolver.setConfiguration(pugConfiguration());
return viewResolver;
}
}
templates/index.pug
doctype html
html
head
meta(charset="UTF-8")
link(rel="stylesheet" type="text/css" href="css/style.css")
title document title
body
p hello, world!
styles located in resources/static/css/styles.css in target folder I can see it in /static/css/styles.css
spring log:
DEBUG org.springframework.web.servlet.DispatcherServlet : GET "/css/style.css", parameters={}
WARN org.springframework.web.servlet.PageNotFound : No mapping for GET /css/style.css
DEBUG org.springframework.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
I tried to move style.css to 'templates' folder, but it did not help