@@ -121,18 +121,25 @@ else if (absolutePath.startsWith("/")) {
121
121
/**
122
122
* Return the path for this resource.
123
123
* <p>If this resource was created using
124
- * {@link ClassPathResource#ClassPathResource(String) ClassPathResource(String)},
125
- * {@link ClassPathResource#ClassPathResource(String, ClassLoader)
126
- * ClassPathResource(String, ClassLoader)}, or
124
+ * {@link ClassPathResource#ClassPathResource(String) ClassPathResource(String)}
125
+ * or {@link ClassPathResource#ClassPathResource(String, ClassLoader)
126
+ * ClassPathResource(String, ClassLoader)}, the returned path is a
127
+ * {@linkplain StringUtils#cleanPath(String) cleaned} version of the
128
+ * <em>absolute path</em> supplied to the constructor, <strong>without</strong>
129
+ * a leading slash.
130
+ * <p>If this resource was created using
127
131
* {@link ClassPathResource#ClassPathResource(String, Class)
128
132
* ClassPathResource(String, Class)} with an absolute path, the returned path
129
133
* is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the
130
- * <em>absolute path</em> supplied to the constructor.
134
+ * <em>absolute path</em> supplied to the constructor, <strong>with</strong>
135
+ * a leading slash.
131
136
* <p>If this resource was created using
132
137
* {@link ClassPathResource#ClassPathResource(String, Class)
133
138
* ClassPathResource(String, Class)} with a relative path, the returned path
134
139
* is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the
135
140
* <em>relative path</em> supplied to the constructor.
141
+ * <p>The path returned by this method cannot be reliably used with
142
+ * {@link ClassLoader#getResource(String)}.
136
143
* <p>If you consistently need the <em>absolute path</em>, use
137
144
* {@link #getAbsolutePath()} instead.
138
145
* @see #getAbsolutePath()
@@ -143,7 +150,9 @@ public final String getPath() {
143
150
144
151
/**
145
152
* Return the <em>absolute path</em> for this resource, as a resource path
146
- * within the class path.
153
+ * within the class path without a leading slash.
154
+ * <p>The path returned by this method is suitable for use with
155
+ * {@link ClassLoader#getResource(String)}.
147
156
* @since 6.0
148
157
* @see #getPath()
149
158
*/
0 commit comments