文件资源操作:
org.springframework.core.io.Resource接口,是为了统一各种类型的资源而定义的
1.访问文件资源
org.springframework.core.io.ClassPathResource 类路径进行访问
org.springframework.core.io.FileSystemResource 文件系统的绝对路径进行访问
org.springframework.web.context.support.ServletContextResource 以相对web应用根目录进行访问
org.springframework.core.io.UrlResource url地址访问文件
org.springframework.util.ResourceUtils 支持用classpaht和file取文件而不需要直接创建Resource实现类
2.本地化文件资源
org.springframework.core.io.support.LocalizedResourceHelper
3.文件内容拷贝
org.springframework.util.FileCopyUtils
4.属性文件操作
org.springframework.core.io.support.EncodedResource 属性文件转码
org.springframework.core.io.support.PropertiesLoaderUtils 加载属性文件
web相关的工具类
1.访问spirngWebApplicationContext
org.springframework.web.context.support.WebApplicationContextUtils
2.简化servlet操作
org.springframework.web.util.WebUtils
3.创建cookie
org.springframework.web.util.CookieGenerator
过滤器和监听类
1.解决请求hibernate延迟加载对象报错
org.springframework.orm.hibernate.support.OpenSessionInViewFilter
2.解决中文乱码
org.springframework.web.filter.CharacterEncodingFilter
3.Introspector缓存消除监听器
org.springframework.web.util.IntrospectorCleanupListener
特殊字符转义
1.html的转义
org.springframework.web.util.HtmlUtils
2.javascript的转义
org.springframework.web.util.JavaScriptUtils
方法参数检查类
1.org.springframework.util.Assert
spring给我们提供了很多的工具类, 应该在我们的日常工作中很好的利用起来. 它可以大大的减轻我们的平时编写代码的长度. 因我们只想用spring的工具类, 而不想把一个大大的spring工程给引入进来. 下面是我从spring3.0.5里抽取出来的工具类. 在最后给出我提取出来的spring代码打成的jar包 spring的里的resouce的概念, 在我们处理io时很有用. 具体信息请参考spring手册 内置的resouce类型
UrlResourceClassPathResourceFileSystemResourceServletContextResourceInputStreamResourceByteArrayResourceEncodedResource 也就是Resource加上encoding, 可以认为是有编码的资源VfsResource(在jboss里经常用到, 相应还有 工具类 VfsUtils)org.springframework.util.xml.ResourceUtils 用于处理表达资源字符串前缀描述资源的工具. 如: "classpath:". 有 getURL, getFile, isFileURL, isJarURL, extractJarFileURL工具类
org.springframework.core.annotation.AnnotationUtils 处理注解org.springframework.core.io.support.PathMatchingResourcePatternResolver 用于处理 ant 匹配风格(com/*.jsp, com/**/*.jsp),找出所有的资源, 结合上面的resource的概念一起使用,对于遍历文件很有用. 具体请详细查看javadocorg.springframework.core.io.support.PropertiesLoaderUtils 加载Properties资源工具类,和Resource结合org.springframework.core.BridgeMethodResolver 桥接方法分析器. 关于桥接方法请参考: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.4.5org.springframework.core.GenericTypeResolver 范型分析器, 在用于对范型方法, 参数分析.org.springframework.core.NestedExceptionUtilsxml工具
org.springframework.util.xml.AbstractStaxContentHandlerorg.springframework.util.xml.AbstractStaxXMLReaderorg.springframework.util.xml.AbstractXMLReaderorg.springframework.util.xml.AbstractXMLStreamReaderorg.springframework.util.xml.DomUtilsorg.springframework.util.xml.SimpleNamespaceContextorg.springframework.util.xml.SimpleSaxErrorHandlerorg.springframework.util.xml.SimpleTransformErrorListenerorg.springframework.util.xml.StaxUtilsorg.springframework.util.xml.TransformerUtils其它工具集
org.springframework.util.xml.AntPathMatcherant风格的处理org.springframework.util.xml.AntPathStringMatcherorg.springframework.util.xml.Assert断言,在我们的参数判断时应该经常用org.springframework.util.xml.CachingMapDecoratororg.springframework.util.xml.ClassUtils用于Class的处理org.springframework.util.xml.CollectionUtils用于处理集合的工具org.springframework.util.xml.CommonsLogWriterorg.springframework.util.xml.CompositeIteratororg.springframework.util.xml.ConcurrencyThrottleSupportorg.springframework.util.xml.CustomizableThreadCreatororg.springframework.util.xml.DefaultPropertiesPersisterorg.springframework.util.xml.DigestUtils摘要处理, 这里有用于md5处理信息的org.springframework.util.xml.FileCopyUtils文件的拷贝处理, 结合Resource的概念一起来处理, 真的是很方便org.springframework.util.xml.FileSystemUtilsorg.springframework.util.xml.LinkedCaseInsensitiveMap key值不区分大小写的LinkedMaporg.springframework.util.xml.LinkedMultiValueMap一个key可以存放多个值的LinkedMaporg.springframework.util.xml.Log4jConfigurer一个log4j的启动加载指定配制文件的工具类org.springframework.util.xml.NumberUtils处理数字的工具类, 有parseNumber 可以把字符串处理成我们指定的数字格式, 还支持format格式, convertNumberToTargetClass 可以实现Number类型的转化. org.springframework.util.xml.ObjectUtils有很多处理null object的方法. 如nullSafeHashCode, nullSafeEquals, isArray, containsElement, addObjectToArray, 等有用的方法org.springframework.util.xml.PatternMatchUtilsspring里用于处理简单的匹配. 如 Spring's typical "xxx*", "*xxx" and "*xxx*" pattern stylesorg.springframework.util.xml.PropertyPlaceholderHelper用于处理占位符的替换org.springframework.util.xml.ReflectionUtils反映常用工具方法. 有 findField, setField, getField, findMethod, invokeMethod等有用的方法org.springframework.util.xml.SerializationUtils用于java的序列化与反序列化. serialize与deserialize方法org.springframework.util.xml.StopWatch一个很好的用于记录执行时间的工具类, 且可以用于任务分阶段的测试时间. 最后支持一个很好看的打印格式. 这个类应该经常用org.springframework.util.xml.StringUtilsorg.springframework.util.xml.SystemPropertyUtilsorg.springframework.util.xml.TypeUtils用于类型相容的判断. isAssignableorg.springframework.util.xml.WeakReferenceMonitor弱引用的监控和web相关的工具
org.springframework.web.util.CookieGeneratororg.springframework.web.util.HtmlCharacterEntityDecoderorg.springframework.web.util.HtmlCharacterEntityReferencesorg.springframework.web.util.HtmlUtilsorg.springframework.web.util.HttpUrlTemplate 这个类用于用字符串模板构建url, 它会自动处理url里的汉字及其它相关的编码. 在读取别人提供的url资源时, 应该经常用 String url = "http://localhost/myapp/{name}/{id}"org.springframework.web.util.JavaScriptUtilsorg.springframework.web.util.Log4jConfigListener 用listener的方式来配制log4j在web环境下的初始化org.springframework.web.util.UriTemplateorg.springframework.web.util.UriUtils处理uri里特殊字符的编码org.springframework.web.util.WebUtilsorg.springframework.web.util. 来源: <http://yingpengfei1215.iteye.com/blog/1604483>