Spring boot webjars: unable to load javascript library through webjar

后端 未结 7 1274
失恋的感觉
失恋的感觉 2020-12-30 08:37

I have a spring boot (I use Thymeleaf for templating) project where I want to use some jQuery libraries.

Unfortunately, the webjars aren\'t loading at all. I have tr

7条回答
  •  被撕碎了的回忆
    2020-12-30 09:08

    if you use servlet 3.x just add :

    1- using java config :

    @Configuration
    @EnableWebMvc
    public class WebConfig extends WebMvcConfigurerAdapter {
    
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
    
                registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/").resourceChain(false);
    
           registry.setOrder(1);
        }
    
    
    }
    

    2- or xml config :

     
       
    
    

提交回复
热议问题