SpringMVC and static resources

后端 未结 5 1326
野的像风
野的像风 2020-12-31 14:55

Im new in java and spring. I\'m trying to make hello world app and don\'t get what i\'m doing wrong.

here is my directory structure:

test_app
-pom.xm         


        
5条回答
  •  别那么骄傲
    2020-12-31 15:37

    Use this , it will work always.Good luck :)

    @Configuration
    @EnableWebMvc
    public class WebConfig extends WebMvcConfigurerAdapter {
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/resources/**").addResourceLocations("/public-resources/").setCachePeriod(31556926);`enter code here`
        }
    }
    

提交回复
热议问题