Spring Boot 实战(5)解决 WebMvcConfigurationSupport 静态资源失效问题

@ConditionalOnProperty(prefix = “spring.mvc.hiddenmethod.filter”, name = “enabled”, matchIfMissing = false)

public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {

return new OrderedHiddenHttpMethodFilter();

}

从源码看出容器中有@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)这个注解。

当容器中没有这个组件的时候,这个自动配置类才生效

因此当选择继承 WebMvcConfigurationSupport 以后还需要 重写它里面的方法。

然而问题又出来了,这样的继承会导致静态资源失效。

如何解决这个问题?

/**

  • An implementation of {@link WebMvcConfigurer} with empty methods allowing

  • subclasses to override only the methods they’re interested in.

  • @author Rossen Stoyanchev

  • @since 3.1

  • @deprecated as of 5.0 {@link WebMvcConfigurer} has default methods (made

  • possible by a Java 8 baseline) and can be implemented directly wi

  • 14
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值