gpt4 book ai didi

java - 将 WebMvcConfigurerAdapter 与基于 xml 的 configuration 混合

转载 作者:行者123 更新时间:2023-12-01 08:52:23 25 4
gpt4 key购买 nike

我可以同时使用以下配置吗?

<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 添加的映射似乎不提供内容。

最佳答案

毕竟我明白了这一点。顺序似乎很重要。调整

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

registry.setOrder(Ordered.HIGHEST_PRECEDENCE)

在WebMvcConfigurerAdapter中解决了这个问题。

关于java - 将 WebMvcConfigurerAdapter 与基于 xml 的 <mvc :resources/> configuration 混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42305619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com