Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:24:16+00:00 2026-06-09T17:24:16+00:00

I would like to somehow inject all HttpMessageConverter instances registered in Spring-MVC. I can

  • 0

I would like to somehow inject all HttpMessageConverter instances registered in Spring-MVC. I can successfully inject all that have been registered via.

private HttpMessageConverter[] converters;
@Autowired
public void setConverters(HttpMessageConverter[] converters) {
    this.converters = converters;
}

However this only injects if the converter was registered inside the context (i.e. if defined outside of <annotation-driven>).

I did figure I would try using <beans:ref inside the <annotation-driven><message-converters> but it is not supported in spring-web 3.1.

Is there some class I can inject that may have a property I could use to get converters? Ideally I’d like to see the order in the filter chain they are registered in too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:24:18+00:00Added an answer on June 9, 2026 at 5:24 pm

    You are right, the message converters are directly instantiated within the RequestMappingHandlerAdapter registered using the <mvc:annotation-driven/> xml tag, and the message-converters subtag explicitly expect the bean to be defined inline.

    However, a workaround is to define the handler adapter and inject in the converters this way:

    <bean name="handlerAdapter" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="webBindingInitializer">
            <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="conversionService" ref="conversionService"></property>
                <property name="validator">
                    <bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
                        <property name="providerClass" value="org.hibernate.validator.HibernateValidator"></property>
                    </bean>
                </property>
            </bean>
        </property>
        <property name="messageConverters">
            <list>
                <ref bean="byteArrayConverter"/>
                <ref bean="jaxbConverter"/>
                <ref bean="jsonConverter"/>
                <bean class="org.springframework.http.converter.StringHttpMessageConverter"></bean>
                <bean class="org.springframework.http.converter.ResourceHttpMessageConverter"></bean>
                <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"></bean>
                <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter"></bean>
            </list>
        </property>
    </bean>
    
    <bean name="byteArrayConverter" class="org.springframework.http.converter.ByteArrayHttpMessageConverter"></bean>
    <bean name="jaxbConverter" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"></bean>
    <bean name="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
    
    <bean name="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
        <property name="useSuffixPatternMatch" value="false"></property>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a static method in my code that I would like somehow to
I would like to somehow paginate my scroll function so that I can choose
I have some hidden inputs like this <input name=exam.normals[1].blahblah ..../> I would like somehow
I would like to avoid the if statement below. Can I somehow copy the
So basically I would like somehow that given an audio file as input (most
I have a tableview that my app shows when it loads, I would like
In ASP.NET MVC, I would like to somehow do custom authorization using the MvcSiteMapProvider.
In Javascript, I have a certain string, and I would like to somehow measure
I would like to somehow instrument a mako.lookup.TemplateLookup such that it applies certain preprocessors
I am running a mysql server. I would like to somehow make sure that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.