Spring Framework
  1. Spring Framework
  2. SPR-9344

Update documentation with regards to overrid RequestMappingHandlerMapping and RequestMappingHandlerAdapter when using the MVC namespace

    Details

    • Last commented by a User:
      false

      Description

      When using `mvc:annotation-driven` automagic, there must be an option to override default beans of RequestMappingHandlerMapping and RequestMappingHandlerAdapter.

      https://github.com/rstoyanchev/spring-mvc-31-demo/issues/4#issuecomment-5338158

      On the link above, we fell to problem, that even if we instantiate our own subclass of RequestMappingHandlerMapping, and put it in right order, before the processing of default bean instance, we're not able to override it, nor configure it.
      Which is causing problems for example to implement @RequestCondition.

      In XML, there should be possibility to ref our own implementation of these beans:

      1. RequestMappingHandlerMapping
      2. RequestMappingHandlerAdapter
      3. ExceptionHandlerExceptionResolver

      Not forcing us to use BeansPostProcessor, as an ugly solution to reconfigure default given beans.

        Activity

        Hide
        Rossen Stoyanchev added a comment -

        Thanks for the suggestion. The key challenge is how to make this possible without introducing two (conflicting) ways of configuring the same thing. For example consider some of the options on mvc:annotation-driven:

        <mvc:annotation-driven conversionService="myConversionService">
          <mvc:message-converters register-defaults="false">
            <bean class="org.springframework...MappingJacksonHttpMessageConverter"/>
          </mvc:message-converters>
        </mvc:annotation-driven>
        

        The conversionService reference and the message-converters are used to customize the created RequestMappingHandlerAdapter. If there was a way to also provide a reference to custom RequestMappingHandlerAdapter, it should be intuitive how it relates to the above configuration if both were present. I know we can say it's illegal to have both but that doesn't help with usability.

        Suggestions are welcome!

        Show
        Rossen Stoyanchev added a comment - Thanks for the suggestion. The key challenge is how to make this possible without introducing two (conflicting) ways of configuring the same thing. For example consider some of the options on mvc:annotation-driven: <mvc:annotation-driven conversionService= "myConversionService" > <mvc:message-converters register-defaults= "false" > <bean class= "org.springframework...MappingJacksonHttpMessageConverter" /> </mvc:message-converters> </mvc:annotation-driven> The conversionService reference and the message-converters are used to customize the created RequestMappingHandlerAdapter. If there was a way to also provide a reference to custom RequestMappingHandlerAdapter, it should be intuitive how it relates to the above configuration if both were present. I know we can say it's illegal to have both but that doesn't help with usability. Suggestions are welcome!
        Hide
        Ulon added a comment - - edited

        In any case the documentation http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestbody is at the moment misleading. It is driving many people into thinking that's the way to do it whether you use it mvc:annotation-driver or not.

        I believe it should be updated with the above mvc:message-converters annotation

        Show
        Ulon added a comment - - edited In any case the documentation http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestbody is at the moment misleading. It is driving many people into thinking that's the way to do it whether you use it mvc:annotation-driver or not. I believe it should be updated with the above mvc:message-converters annotation
        Hide
        Rossen Stoyanchev added a comment -

        Ok I'll add links to examples with the MVC namespace and MVC java config there, which are further below in section 16.14.

        Show
        Rossen Stoyanchev added a comment - Ok I'll add links to examples with the MVC namespace and MVC java config there, which are further below in section 16.14.

          People

          • Assignee:
            Rossen Stoyanchev
            Reporter:
            Marek Sebera
            Last updater:
            Rossen Stoyanchev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 48 weeks, 4 days ago