Spring学习笔记
目录
简介
在springboot中,如果想访问静态资源,那么就需要用到ResourceLoader接口,ResourceLoader接口专门负责加载Resource对象–描述静态资源的对象,在JDK包中,Resource对象对应java.net.URL类,只不过功能比URL更加丰富而已。
认识Resource接口
public interface Resource extends InputStreamSource {
boolean exists();
default boolean isReadable() {
return exists();
}
default boolean isOpen() {
return false;
}
default boolean isFile() {
return false;
}
URL getURL() throws IOException;
URI getURI() throws IOException;
File getFile() throws IOException;
default ReadableByteChannel readableChannel() throws IOException {
return Channels.newChannel(getInputStream());
}
long contentLength() throws IOException;
long lastModified() throws IOException;
Resource createRelative(String relativePath) throws IOException;
@Nullable
String getFilename();
String getDescription();
}