Skip to content

Make it easier to remove items from HttpMessageConverters #1482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philwebb opened this issue Sep 1, 2014 · 2 comments
Closed

Make it easier to remove items from HttpMessageConverters #1482

philwebb opened this issue Sep 1, 2014 · 2 comments
Milestone

Comments

@philwebb
Copy link
Member

philwebb commented Sep 1, 2014

Currently it isn't very easy to remove an item from HttpMessageConverters. See http://stackoverflow.com/questions/23480517/spring-hateoas-w-spring-boot-jaxb-marshal-error-when-returning-a-resourcest/23489883?noredirect=1#comment39943077_23489883

@philwebb philwebb added this to the 1.1.6 milestone Sep 1, 2014
@drdamour
Copy link

drdamour commented Nov 5, 2014

I'm at a lost as to how to actually use this new functionality. Can you provide an example? Should i be registering a new HttpMessageConverters bean in a @configuration class?

@philwebb
Copy link
Member Author

philwebb commented Nov 5, 2014

@drdamour Yes, you need to register the HttpMessageConverters as a bean and override postProcessConverters.

See

protected List<HttpMessageConverter<?>> postProcessConverters(
List<HttpMessageConverter<?>> converters) {
for (Iterator<HttpMessageConverter<?>> iterator = converters.iterator(); iterator
.hasNext();) {
if (iterator.next() instanceof Jaxb2RootElementHttpMessageConverter) {
iterator.remove();
}
}
return converters;
for an example that removes an item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants