What does do?

前端 未结 4 1294
没有蜡笔的小新
没有蜡笔的小新 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

    mvc:annotation-driven tag do extra work from context:component-scan tag

    The tag registers the Handler Mapping and Handler Adapter required to dispatch requests to your @Controllers:

    tag helps registering the following components.

    DefaultAnnotationHandlerMapping - This is a HandlerMapping implementation which maps the HTTP requests to the handler methods defined using the @RequestMapping annotation.

    AnnotationMethodHandlerAdapter - It is responsible for scanning the controllers to identify methods (and parameters) annotated with @MVC annotations. It scans and caches handler methods annotated with @RequestMapping. Also handles the @RequestParam, @ModelAttribute, @SessionAttributes and @InitBinder annotations.

    ConfigurableWebBindingInitializer - The initializer for the Web Data Binder. Helps in declaratively configuring the Web Binder with validators, conversion services, property editors, etc.

    LocalValidatorFactoryBean - Implements the validator interface and enables JSR303 validation. This is injected into ConfigurableWebBindingInitializer. FormattingConversionServiceFactoryBean - A conversion factory that returns conversion services for basic objects like date and numbers. This factory is again injected into ConfigurableWebBindingInitializer.

    Message Converters
    ByteArrayHttpMessageConverter - A HTTP request message converter that reads a HTTP message body and returns a byte stream. It can also read a byte stream and construct a response body. Used for receiving and sending documents like PDF, XLS, etc.
    StringHttpMessageConverter - A HTTP request message converter that reads a plain text request body and binds it to a String object. And vice-versa with response.
    FormHttpMessageConverter - A HTTP request message converter that reads a form encoded request body and binds it to a form Binding object.
    SourceHttpMessageConverter - A HTTP request converter that converts a XML message body to/from Binding Object.

    If we do not use mvc:annotation-driven tag then we have to do register these components manually in xml file in order to use them , which results in too much extra work.

提交回复
热议问题