Spring boot webjars: unable to load javascript library through webjar

后端 未结 7 1285
失恋的感觉
失恋的感觉 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 :

    <mvc:resources mapping="/webjars/**" location="/webjars/"> 
      <mvc:resource-chain resource-cache="false" /> 
    </mvc:resources>
    
    0 讨论(0)
提交回复
热议问题