我還沒有嘗試過,但可以嘗試擴展ResourceHttpRequestHandler並使用BeanFactoryPostProcessor將ResourceHttpRequestHandler類替換爲您的自定義類。類似的解決方案,給出here
樣本...
public class ResourceHttpRequestHandlerReplacer implements BeanFactoryPostProcessor {
public void postProcessBeanFactory(ConfigurableListableBeanFactory factory)
throws BeansException {
String[] names = factory.getBeanNamesForType(ResourceHttpRequestHandler.class);
for (String name: names) {
BeanDefinition bd = factory.getBeanDefinition(name);
bd.setBeanClassName("org.myProject.CustomResourceHttpRequestHandler");
}
}
}