CSS not loading in Spring Boot

前端 未结 8 2160
渐次进展
渐次进展 2020-12-05 00:12

I am new to spring frame work and spring boot.I am trying to add the static html file with CSS,javascript,js. the file structure is

8条回答
  •  醉梦人生
    2020-12-05 00:54

     
        
    [this is the image for my project structure. i added the webapp directory to support .jsp files.this method request.getContextPath() worked for me. Hope i help someone with this... it gets the path so long as it exists. 
    Nb. You should have a resolver bean in your webconfig
    `enter code here`@Bean
    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver resolver = new   `enter code here`InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/jsp/");
        resolver.setSuffix(".jsp");
        return resolver;
    }` 
    for the added directory][1]

提交回复
热议问题