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 ability for CNVR to search view names that use file extensions [SPR-7117] #11777

Closed
spring-projects-issues opened this issue Apr 21, 2010 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

David Turanski opened SPR-7117 and commented

A common pattern for supporting multiple document types with a single controller is to append the file extension to the bean name and use BeanNameViewResolver. For example if an application requires both Excel and PDF renderings of the logical view name "view", the corresponding bean names would be "view.xls" and "view.pdf". CNVR currently does not support this pattern since it only tries to resolve "view"

The proposed enhancement uses the mediaTypes map (or JAF in some cases) to obtain the file extension. The request can use path extension, accept header, or request parameter containing the extension. The mediaTypes map is reversed searched to obtain the file extension corresponding to each requested media type (Accept header can specify multiple types). A second pass is made through the view resolvers appending "." + file extension to the view name

A patch is attached


Attachments:

@spring-projects-issues
Copy link
Collaborator Author

David Turanski commented

I Just noticed a subtle bug in the patch. This is a corner case, but the code that appends the file extension to the view name does not reinitialize the view name properly, so if there are multiple media types requested the second extension would append to the first, etc.

@spring-projects-issues
Copy link
Collaborator Author

David Turanski commented

Updated to fix bug noted in previous comment

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Done. I've changed the patch a little, to make it clearer (for me) to see what's going on. Let me know what you think.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants