ClassPathResource 在類路徑下讀取資源
public final String getPath()
public boolean exists()
public InputStream getInputStream()
WebUtils 獲取web資源工具類
public static String getRealPath(ServletContext servletContext, String path)
public static Object getSessionAttribute(HttpServletRequest request, String name)
public static File getTempDir(ServletContext servletContext)
ServletRequestUtils 提供獲取請求參數 并自動類型轉換的功能
public static Integer getIntParameter(ServletRequest request, String name)
public static int[] getIntParameters(ServletRequest request, String name)
public static Long getLongParameter(ServletRequest request, String name)
StringUtils 提供對字符串操作的工具類
public static String[] split(String toSplit, String delimiter)
public static String collectionToCommaDelimitedString(Collection<?> coll)
public static boolean hasLength(String str)
SerializationUtils 提供序列化與反序列化
public static byte[] serialize(Object object)
public static Object deserialize(byte[] bytes)
FactoryBean 通過實現該接口可以將我們自定義的Bean注入到Spring的容器當中去
public interface FactoryBean {
T getObject() throws Exception;
Class<?> getObjectType();
boolean isSingleton();
}
ApplicationContextAware 實現這個接口可以將 ApplicationContext 注入進來
public interface ApplicationContextAware extends Aware {
void setApplicationContext(ApplicationContext applicationContext) throws BeansException;
}
InitializingBean 實現該接口可以做一些初始化動作,afterPropertiesSet方法會在容器初始化后被自動調用
public interface InitializingBean {
void afterPropertiesSet() throws Exception;
}
DisposableBean 實現該接口可以再Spring容器銷毀時調用,可以在這個方法中做一些比如清理資源的動作
public interface DisposableBean {
void destroy() throws Exception;
}
BeanNameAware 實現該接口,Spring容器在啟動后會把當前Bean的名字注入進來
public interface BeanNameAware extends Aware {
void setBeanName(String name);
}
ResourceLoaderAware 實現該接口可以注入ResourceLoader對象,通過它可以很方便的加載一些系統資源
public interface ResourceLoaderAware extends Aware {
void setResourceLoader(ResourceLoader resourceLoader);
}