日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

springboot工具类

發(fā)布時間:2023/12/10 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springboot工具类 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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 提供獲取請求參數(shù) 并自動類型轉(zhuǎn)換的功能

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 通過實現(xiàn)該接口可以將我們自定義的Bean注入到Spring的容器當中去
public interface FactoryBean {
T getObject() throws Exception;
Class<?> getObjectType();
boolean isSingleton();
}

ApplicationContextAware 實現(xiàn)這個接口可以將 ApplicationContext 注入進來
public interface ApplicationContextAware extends Aware {
void setApplicationContext(ApplicationContext applicationContext) throws BeansException;
}

InitializingBean 實現(xiàn)該接口可以做一些初始化動作,afterPropertiesSet方法會在容器初始化后被自動調(diào)用
public interface InitializingBean {
void afterPropertiesSet() throws Exception;
}

DisposableBean 實現(xiàn)該接口可以再Spring容器銷毀時調(diào)用,可以在這個方法中做一些比如清理資源的動作
public interface DisposableBean {
void destroy() throws Exception;
}

BeanNameAware 實現(xiàn)該接口,Spring容器在啟動后會把當前Bean的名字注入進來
public interface BeanNameAware extends Aware {
void setBeanName(String name);
}

ResourceLoaderAware 實現(xiàn)該接口可以注入ResourceLoader對象,通過它可以很方便的加載一些系統(tǒng)資源
public interface ResourceLoaderAware extends Aware {
void setResourceLoader(ResourceLoader resourceLoader);
}

總結(jié)

以上是生活随笔為你收集整理的springboot工具类的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。