Equivalent of mvc:default-servlet-handler in Spring annotation-based configuration?

后端 未结 4 2386
野趣味
野趣味 2021-02-19 00:45

Is it possible to have the equivalent of defined in an AnnotationConfig(Web)ApplicationContext? Right now I have:<

4条回答
  •  囚心锁ツ
    2021-02-19 01:09

    If you are using Spring 3.1 with WebMvc, you can configure default servlet handling like this:

    @Configuration
    @EnableWebMvc
    public class MvcConfig extends WebMvcConfigurerAdapter {
    
        @Override
        public void configureDefaultServletHandling(
                DefaultServletHandlerConfigurer configurer) {
            configurer.enable();
        }
    }
    

提交回复
热议问题