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

Url suffix after dot is omitted [SPR-6518] #11184

Closed
spring-projects-issues opened this issue Dec 4, 2009 · 3 comments
Closed

Url suffix after dot is omitted [SPR-6518] #11184

spring-projects-issues opened this issue Dec 4, 2009 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 4, 2009

Ave Kar opened SPR-6518 and commented

Using @Pathvariable to pass in filenames omits the extension.

i.e.: If passing in /admin/documents/foo.txt

@RequestMapping("/admin/documents/{fileName}")
public void foo(@PathVariable String fileName)
{
// fileName will come in as 'foo' instead of 'foo.txt'
}


Affects: 3.0 M4, 3.0 RC1, 3.0 RC2, 3.0 RC3

Reference URL: http://forum.springsource.org/showthread.php?t=77491

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

By default, all @RequestMapping patterns are suffixed with .* So effectively, @RequestMapping("/admin/documents/{fileName}") will result in two patterns: /admin/documents/{filename} and /admin/documents/{filename}.*. And this last pattern "wins" when a request for /admin/documents/foo.txt comes in.

You can disable this behavior by explicitly configuring a DefaultAnnotationHandlerMapping in you servlet app context (thus overriding the default), and setting the 'useDefaultSuffixPattern' property to false (default is true).

@spring-projects-issues
Copy link
Collaborator Author

Ave Kar commented

Setting the useDefaultSuffixPattern property to false allows the return files as with extension but this forces using /admin/documents/{fileName}.{fileExtension} in the path since files HelloWorld.java do not map to the /admin/documents/{fileName} path. If the file does not have to have an extension i.e. HelloWorld then that won't map to /admin/documents/{fileName}.{fileExtension}.
This forces the user to have two separate requests that ultimately do the same thing for files that have extensions and files that don't. Will this be fixed in the next version so that all files are mapped to {fileName}?

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Yes. I've made some recent changes in the way uri template variables are matched, and HelloWorld.java now does map to the /admin/documents/{fileName}.

You could try a recent (as of yesterday) snapshot and see if it works for you.

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) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants