- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我想添加资源处理程序。在论坛中,他们使用 WebMvcConfigurationSupport
:http://forum.springsource.org/showthread.php?116068-How-to-configure-lt-mvc-resources-gt-mapping-to-take-precedence-over-RequestMapping&p=384066#post384066
文档说 WebMvcConfigurerAdapter
:http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/web/servlet/config/annotation/EnableWebMvc.html
有什么区别和使用哪一个?两者都有我需要的 addResourceHandlers
方法。
这是我目前的类(class):
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
public @Override void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources");
}
public @Bean TilesViewResolver tilesViewResolver() {
return new TilesViewResolver();
}
public @Bean TilesConfigurer tilesConfigurer() {
TilesConfigurer ret = new TilesConfigurer();
ret.setDefinitions(new String[] { "classpath:tiles.xml" });
return ret;
}
}
最佳答案
答案在您上面引用的文档中:
If the customization options of WebMvcConfigurer do not expose something you need to configure, consider removing the @EnableWebMvc annotation and extending directly from WebMvcConfigurationSupport overriding selected @Bean methods
简而言之,如果@EnableWebMvc 适合您,则无需进一步查看。
关于spring - WebMvcConfigurationSupport 和 WebMvcConfigurerAdapter 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17898606/
我已经使用 WebMvcConfigurerAdapter 一段时间了。由于我无法使用 getInterceptors() 方法获取所有已注册的拦截器,因此我已切换到 WebMvcConfigurat
我想在 Windows 中使用 WebMvcConfigurerAdapter 添加资源处理程序,但在 Linux 中它不起作用,所以我添加了 WebMvcConfigurationSupport。
我还需要扩展 WebMvcConfigurationSupport 类修改两件事: @Configuration public class WebConfig extends WebMvcConfig
我想添加资源处理程序。在论坛中,他们使用 WebMvcConfigurationSupport:http://forum.springsource.org/showthread.php?116068-
由于 WebMvcConfigurerAdapter 从 Spring 5.0 开始已被弃用,我已将其更改为 WebMvcConfigurationSupport,但我得到的响应为空值。 { "key
我扩展了 WebMvcConfigurationSupport 来实现 api 版本控制方案 - 即 @Configuration public class ApiVersionConfigurati
我正在尝试使用 Java Config 扩展 WebMvcConfigurationSupport 在 Spring 中注册 HandlerInterceptor 实例。我正在创建一个带有注释的库,当
在传统的 Spring MVC 中,我可以扩展 WebMvcConfigurationSupport并执行以下操作: @Override public void configureContentNeg
我有一个带有 swagger 文件的 springboot 应用程序。我使用任何 swagger Maven 插件,它都可以工作。 我的 pom.xml 文件: io.swa
我是一名优秀的程序员,十分优秀!