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

Add support for content negotiation based on a request parameter value [SPR-5870] #10539

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

Comments

@spring-projects-issues
Copy link
Collaborator

Rostislav Hristov opened SPR-5870 and commented

Content negotiation based on a request parameter can be a nice addition to the framework. Such a capability is already available in Grails (http://grails.org/doc/1.0.x/guide/single.html#6.8%20Content%20Negotiation). I was able to implement it and use it by extending the ContentNegotiatingViewResolver but it will be great if it can become a part of the framework.

Such a feature is required in a scenario where you have an HTML FORM which allows you to select the format you want to receive after submitting it. The only way to implement such a form unobtrusively (without JavaScript) is to use a SELECT dropdown defining the requested media extension. Without JavaScript you cannot change the FORM action address or the request header. Even with JavaScript support it's much more easier to use a request parameter than any other implementation.

As a result of this improvement the content negotiation will be available in the following scenarious:
/book/list.xml
/book/list?format=xml
/book/list (with proper Accept header)


Affects: 3.0 M3

Attachments:

1 votes, 1 watchers

@spring-projects-issues
Copy link
Collaborator Author

Rostislav Hristov commented

The following patch enhances the ContentNegotiatingViewResolver class by adding an implementation and documentation of the described feature. It introduces two configurable properties named "favorParameter" and "parameterName" which should allow customization of the feature.

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Done. Thanks for the patch!

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 M4 milestone Jan 11, 2019
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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants