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
Allow valid file extension paths for content negotiation to be specified [SPR-7632] #12288
Comments
Dave Syer commented An neat solution would be to allow the controller to access the removed portion of the path, e.g. with
|
Rossen Stoyanchev commented Currently, you can turn suffix pattern matching on and off wholesale only through the HandlerMapping useSuffixPatternMatch property. When off the extension can be extracted like this: @RequestMapping(value = "/jobs/{jobName}.{ext:job}", method = RequestMethod.GET)
public String doSomething(@PathVariable String jobName, @PathVariable String ext) {
// ...
} We may be able to do something about smarter suffix pattern matching with the content negotiation improvements planned for 3.2 (see #13120 and its umbrella ticket #13057). In which case you'd be able to do the above without turning off suffix pattern matching wholesale. |
Rossen Stoyanchev commented Modified title (was: "Allow valid file extension paths to be specified in DispatcherServlet") |
Rossen Stoyanchev commented This is now resolved. As long as you have configured valid file extensions through the newly added ContentNegotiationManager, those extensions will be the only ones recognized. See the commit comment for more details. |
sandip commented I am using version 3.2.4 of spring and still facing same issue , do i need to do some more configurations ? |
Rossen Stoyanchev commented Besides configuring content negotiation itself, you also need to enable it (see this property). |
Add a regexp in mapping pattern for /api/2/users/{id} See spring-projects/spring-framework#10832 or spring-projects/spring-framework#12288
spring-projects-issues commentedOct 8, 2010
•
edited
Dave Syer opened SPR-7632 and commented
Allow valid file extension paths to be specified in DispatcherServlet. My use case is
I need .html and .json to be valid extensions (stripped off by the dispatcher), but other . separated jobName values are legal and should be presented as they are (e.g. my.job or my.job.html both resolve to my.job).
The current behaviour is simply to truncate at the first period. Even with a regex pattern
{jobName:.*
} we truncate the path, so the only way to make it work is to add HttpServletRequest to all controller methods and extract the parameter manually (back to Spring 2.5).Affects: 3.0.6
This issue is a sub-task of #13057
Issue Links:
@PathVariable
will cut off the last point ("is duplicated by")Referenced from: commits 4fd7645
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: