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

dot in URL breaks @PathVariable binding [SPR-5778] #10448

Closed
spring-projects-issues opened this issue May 21, 2009 · 6 comments
Closed

dot in URL breaks @PathVariable binding [SPR-5778] #10448

spring-projects-issues opened this issue May 21, 2009 · 6 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 21, 2009

Kenny MacLeod opened SPR-5778 and commented

Take the following REST endpoint:

@RequestMapping("/lat/{latitude}/long/{longitude}")
public void testLatLong(@PathVariable String latitude, @PathVariable String longitude) {
	System.out.println("Latitude = " + latitude);
	System.out.println("Longitude = " + longitude);
}

If you hit this with the URL

/lat/123/long/456 

it works fine, with both variables binding as expected. If, however, you try

/lat/0.1/long/0.1

you get

Latitude='0.1', longitude='0'

The second dot in the URL is causing the trailing 1 to be stripped off somewhere, so that latitude is bound correctly, but longitude isn't.

If you add a trailing slash to the mapping (i.e. "/lat/{latitude}/long/{longitude}/") and add a trailing slash to the URL, it works fine.

This may be related to #8317, but that issue looks to have been corrupted somehow (affects M3, fixed for M3?)


Affects: 3.0 M3

1 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 21, 2009

Kenny MacLeod commented

Sorry, that should've been #10307

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Added markup.

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

This is an unfortunate side-effect of the implicit matching for .* in the DefaultAnnotationHandlerMapping. Basically, every RequestMapping you specify also matches for pattern.* and pattern/..

You can disable this setting by defining an explicit DefaultAnnotationHandlerMapping in your servlet context, and setting the useDefaultSuffixPattern to false (the default is true).

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Reopened because of wrong resolution.

@spring-projects-issues
Copy link
Collaborator Author

Giridhar Nandigam commented

Arjen,

Will this issue not be fixed or is it resolved?

@spring-projects-issues
Copy link
Collaborator Author

Giridhar Nandigam commented

The resolution is to use useDefaultSuffixPattern = false on DefaultAnnotationHandlerMapping.

Mis-understood by wrong resolution.

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: bug A general bug label Jan 12, 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) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

2 participants