Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
We had an issue where we had a RequestMapping that produces="application/json". Our client was not sending an "Accept" header and as a result did not see the json response (received a 404) since the only thing that this method is supposed to produce is JSON.
According to the w3c spec if an "Accept" header is not supplied the default should be "*/*" and if this had been provided then the client would have received the "application/json" response as intended.
The ContentNegotiatingViewResolver does support a defaultMediaType but providing "*/*" does nothing because by the time that the code reaches this default it has already passed the earlier part of the code that looks at the "producibles" to know that it should reply with "application/json".
I would propose refactoring the ContentNegotiatingViewResolver such that when the accept header is not provided and a defaultMediaType is specified that the accept header should be considered to be "*/*" so that it can match the produces attribute.