What does do?

前端 未结 4 1295
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 14:48

I use filenames in my REST API (example: GET http://xxx/api/myImage.jpg) problem is @PathVariable dropped \".jpg\". this problems already asked few times in here and answer

4条回答
  •  忘掉有多难
    2020-12-03 15:23

    Before I provide certain points let me clear up the answer provided by Roy is not accurate. You don't have to provide mvc:annotation-driven tag to instantiate default beans. This tag can be used Spring 3.0+ to enable new feature introduced from Spring 3.0

    (Do not use it if you want backward compatibility, especially if you are using old controller based classes like MultiActionController, SimpleFormController)

    Now lets come to what this tag actually does -

    Prior to Spring 3.1 default beans used where

    1. DefaultAnnotationHandlerMapping
    2. AnnotationMethodHandlerAdapter
    3. AnnotationMethodHandlerExceptionResolver

    These are deprecated in Spring 3.1 and if you use above mentioned tag it will be replaced by -

    1. RequestMappingHandlerMapping
    2. RequestMappingHandlerAdapter
    3. ExceptionHandlerExceptionResolver

    DefaultAnnotationHandlerMapping decided which controller to use and the AnnotationMethodHandlerAdapter selected the actual method that handled the request. RequestMappingHandlerMapping does both the tasks. Therefore the request is directly mapped right to the method.

    There are other infrastructure beans that are instantiated by these tag (chained in addition to defaults) like - MappedInterceptor, ConfigurableWebBindingInitializer, SessionFlashManager, ContentNegociationManager etc. I am not going to explain these :) as they each are long answers themselves, so google it for more info.

    PS : And yes Spring 3.1+ automatically expose @PathVariables to the model. Also you have mvc:interceptors tag. But I think it is not related to . I would highly recommend read - http://spring.io/blog/2009/12/21/mvc-simplifications-in-spring-3-0/

提交回复
热议问题