相关疑难解决方法(0)

WebMvcConfigurationSupport和WebMvcConfigurerAdapter之间的区别

我想添加资源处理程序.在他们使用的论坛中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我需要的方法.

这是我目前的课程:

@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;
    }
}
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc

30
推荐指数
3
解决办法
3万
查看次数

标签 统计

spring ×1

spring-mvc ×1