2017-02-17 26 views
0

可以同時使用以下配置嗎?將WebMvcConfigurerAdapter與基於xml的<mvc:resources />配置混合

<mvc:resources mapping="/static/**" location="/static/, classpath:/static/"/> 

@Configuration 
@EnableWebMvc 
public class ResourceMappingsAdapter extends WebMvcConfigurerAdapter { 
... 
@Override 
    public void addResourceHandlers(ResourceHandlerRegistry registry) { 
registry.addResourceHandler("/anotherStatic/", "file:///..."); 
} 

映射從WebMvcConfigurerAdapter增加似乎並沒有爲服務內容。

回答

0

畢竟我想通了。該命令似乎很重要。調整

<mvc:resources mapping="/static/**" location="/static/" order="1"/> 

registry.setOrder(Ordered.HIGHEST_PRECEDENCE) 

在WebMvcConfigurerAdapter解決的問題。

相關問題