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

后端 未结 4 2398
野趣味
野趣味 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:14

    @Bean
    public DefaultServletHttpRequestHandler defaultServletHttpRequestHandler() {
      return new DefaultServletHttpRequestHandler();
    }
    
    @Bean
    public SimpleUrlHandlerMapping simpleUrlHandlerMapping() {
      Map urlMap = new ManagedMap();
      urlMap.put("/**", defaultServletHandlerName);
    
      SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
      hm.setUrlMap(urlMap);
      return hm;
    }
    

提交回复
热议问题