Where do CSS and JavaScript files go in a Maven web app project?

前端 未结 5 1590
余生分开走
余生分开走 2020-12-02 07:40

I am switching to use Maven for my Spring web app projects and I am running into a simple issue. I am not sure where to put the CSS and JS files in the new project structure

5条回答
  •  难免孤独
    2020-12-02 08:13

    The best solution I found for this problem is to use Java Configuration

    @Configuration
     @EnableWebMvc
     public class WebAppConfig implements WebMvcConfigurer {
         
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
        }
    }
    

提交回复
热议问题