Skip to content
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

ContentNegotiatingViewResolver [SPR-10761] #15387

Closed
spring-issuemaster opened this issue Jul 19, 2013 · 2 comments
Assignees
Labels

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jul 19, 2013

Jarrod Cuzens opened SPR-10761 and commented

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.


Affects: 3.1.3

Issue Links:

  • #15311 ContentNegotiatingViewResolver does not select any views if no content types are requested
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 22, 2013

Rossen Stoyanchev commented

I think I just fixed this. Can you take a look at this commit and confirm if this is what you had in mind?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 22, 2013

Rossen Stoyanchev commented

Also see comment under #15311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.