是您要寻找的:
URI uri = new URI("http://example.com/foo/bar/42?param=true");String path = uri.getPath();String idStr = path.substring(path.lastIndexOf('/') + 1);int id = Integer.parseInt(idStr);或者
URI uri = new URI("http://example.com/foo/bar/42?param=true");String[] segments = uri.getPath().split("/");String idStr = segments[segments.length-1];int id = Integer.parseInt(idStr);


