You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request mapping only takes into account the number of path chunks (the number of slashes in the url) when finding the corresponding java method to call. It means that the two urls like
"/services/test/projects/1/files/2" and "/services/test/projects/1/images/3" are mapped to the same method. I created a simple test :
public class Test {
@RequestMapping("/projects/{projectId}/files/{fileId}")
public String test1(@PathVariable("projectId") int projectId, @PathVariable("fileId") int fileId) {
return "test1";
}
@RequestMapping("/projects/{projectId}/images/{imageId}")
public String test2(@PathVariable("projectId") int projectId, @PathVariable("imageId") int imageId) {
return "test2";
}
public static void main(String[] args) {
final ManagedServiceBuilder managedServiceBuilder = ManagedServiceBuilder.managedServiceBuilder().setRootURI("/services").setPort(2334);
managedServiceBuilder.addEndpointService("test", new Test());
EndpointServerBuilder builder = managedServiceBuilder.getEndpointServerBuilder();
ServiceEndpointServer server = builder.build();
server.startServer();
HttpClient tmService = HttpClientBuilder.httpClientBuilder().setHost("localhost").setPort(2334).build();
tmService.startClient();
System.out.println(tmService.get("/services/test/projects/1/files/2"));
System.out.println(tmService.get("/services/test/projects/1/images/3"));
}
}
Request mapping only takes into account the number of path chunks (the number of slashes in the url) when finding the corresponding java method to call. It means that the two urls like
"/services/test/projects/1/files/2" and "/services/test/projects/1/images/3" are mapped to the same method. I created a simple test :
If you run the test, you'll get:
The first method is called in both cases, which is incorrect.
The text was updated successfully, but these errors were encountered: