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

Content negotiation [SPR-5452] #10125

Closed
spring-projects-issues opened this issue Feb 2, 2009 · 0 comments
Closed

Content negotiation [SPR-5452] #10125

spring-projects-issues opened this issue Feb 2, 2009 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 2, 2009

Arjen Poutsma opened SPR-5452 and commented

Spring-MVC currently let's the server decide which view to render for a given request, through it's View, view name and ViewResolver abstractions. In a more RESTful scenario, it is a best practice to let the client decide the representation, via the "Accept" HTTP header. The server responds with the delivered representation via the "Content-Type" header.

One issue with the "Accept" header is that is impossible to change it in a web browser; it is always fixed to "text/html, image/gif", etc. Looking at the file extension is a good workaround, i.e. http://example.com/hotels.pdf retrieves the PDF view of the hotel list, as does http://example.com/hotels with an Accept header of "application/x-pdf".

We should create a ViewResolver which respects the client-side Accept header, but also looks at file extensions. This view resolver acts as an adapter other ViewResolvers, simply delegating to the correct one given a particular media type.


This issue is a sub-task of #9097

Referenced from: commits df563df

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants