diff --git a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java index 79d6fea794a..be56956d68d 100644 --- a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java @@ -120,18 +120,21 @@ public class ClassPathResource extends AbstractFileResolvingResource { /** * Return the path for this resource. - *
If this {@code ClassPathResource} was created using - * {@link ClassPathResource#ClassPathResource(String) ClassPathResource(String)} or + *
If this resource was created using + * {@link ClassPathResource#ClassPathResource(String) ClassPathResource(String)}, * {@link ClassPathResource#ClassPathResource(String, ClassLoader) - * ClassPathResource(String, ClassLoader)}, the returned path is a - * {@linkplain StringUtils#cleanPath(String) cleaned} version of the + * ClassPathResource(String, ClassLoader)}, or + * {@link ClassPathResource#ClassPathResource(String, Class) + * ClassPathResource(String, Class)} with an absolute path, the returned path + * is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the * absolute path supplied to the constructor. - *
If this {@code ClassPathResource} was created using - * {@link ClassPathResource#ClassPathResource(String, Class)}, the - * returned path is a {@linkplain StringUtils#cleanPath(String) cleaned} - * version of the relative path supplied to the constructor. - *
If you need the absolute path, use {@link #getAbsolutePath()} - * instead. + *
If this resource was created using + * {@link ClassPathResource#ClassPathResource(String, Class) + * ClassPathResource(String, Class)} with a relative path, the returned path + * is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the + * relative path supplied to the constructor. + *
If you consistently need the absolute path, use + * {@link #getAbsolutePath()} instead. * @see #getAbsolutePath() */ public final String getPath() {