Skip to content

Can't load styles #6

@zvmv

Description

@zvmv

I Try to load style from my resources folder (/resources/static/css/styles.css) but get 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions