2017-02-17 48 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解决的问题。