SpringMVC 常用工具类与接口
2024-10-19 04:30:10
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<T> 通过实现该接口可以将我们自定义的Bean注入到Spring的容器当中去
public interface FactoryBean<T> {
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);
}
最新文章
- inline-block和float
- 使用PowerDesigner把oom设计图导出jpg格式的图片
- aptana studio 3汉化方法 及支持jquery的方法
- BZOJ4347 : [POI2016]Nim z utrudnieniem
- input中如何输入逆写的中文句子
- pku3670 Eating Together
- 字符串(后缀数组||SAM):NOI2015 品酒大会
- 用java写bp神经网络(一)
- nginx-lua实现简单权限控制
- Android高仿雅虎天气(两)---代码结构分析
- find用法详解
- 28. pt-table-sync
- spark常见异常汇总
- [PA2014]Bohater
- 【Visual Studio 扩展工具】使用ComponentOne中的GroupDefinition和SortDefinition属性保存和还原布局
- tips:Java基本数据类型大小比较
- Debug的使用
- Scala进阶之路-面向对象编程之类的成员详解
- Spark ML 几种 归一化(规范化)方法总结
- ThinkPHP学习(一)