Skip to content

PathVariables of type double [SPR-6528] #11194

@spring-projects-issues

Description

@spring-projects-issues

Christopher Anderson opened SPR-6528 and commented

Take the following REST endpoint:

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

If you hit this with the URL

/lat/123/long/456 

However, if the URL contains doubles with a decimal place e.g.:

/lat/2.3/long/445

The endpoint is not longer hit, i.e. we get a 404.

Interestingly, if we change the type of the PathVariables to String:

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

It will not work when latitude or longitude contains a fullstop. However, a comma will work instead of a fullstop in this case.


Affects: 3.0 M4

Issue Links:

Referenced from: commits 8678652

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions