org.springframework.util.Assert
Assert翻译为中文为"断言".用过JUNIT的应该都知道这个概念了.
就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常.
Assert经常用于:
1.判断METHOD的参数是否属于正常值.
2.JUNIT中使用.
我发现SPRING1.2.6里面有BUG
请看:
org.springframework.core.io.support.EncodedResource中
public EncodedResource(Resource resource, String encoding) {
Assert.notNull("Resource is required");
this.resource = resource;
this.encoding = encoding;
}
Assert.notNull("Resource is required");
这句应该为
Assert.notNull(resource,"Resource is required");
不然resource都没传过来,还断什么言啊,呵呵.
 
------------------------------------------------------------------------
上面是在网上看到了,但是我进入spring里面看了一下源码,如下:
/**
* Assert that an object is not <code>null</code> .
* <pre class="code">Assert.notNull(clazz, "The class must not be null");</pre>
* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if the object is <code>null</code>
*/
public static void notNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}
该函数的意思是传入的object必须不能为空。如果为空就抛出异常。

spring 中的断言的作用的更多相关文章

  1. EnableAutoConfiguration注解 Spring中@Import注解的作用和使用

    EnableAutoConfiguration注解 http://www.51gjie.com/javaweb/1046.html springboot@EnableAutoConfiguration ...

  2. Spring中<context:annotation-config/>的作用

    spring中<context:annotation-config/>配置的作用,现记录如下: <context:annotation-config/>的作用是向Spring容 ...

  3. Spring中的beanPostProcess的作用

    BeanPostProcessor是Spring框架中非常重要的bean之一.贯穿在Spring容器中bean的初始化的整个过程. Spring中的beanpostProcess体系结构如下: 可以看 ...

  4. cache在spring中使用

    一:参考文章 (1)http://haohaoxuexi.iteye.com/blog/2123030  Spring使用Cache,这篇文章讲的比较详细. 注:本文是对参考文章和实际使用中经验的总结 ...

  5. spring中scope(作用越)理解

    今天总结了一下spring中作用域scope的用法.在spring中作用域通过配置文件形式的用法如下. <bean id="role" class="spring. ...

  6. spring中的BeanFactory与ApplicationContext的作用和区别?

    BeanFactory类关系继承图 1. BeanFactory类结构体系: BeanFactory接口及其子类定义了Spring IoC容器体系结构,由于BeanFactory体系非常的庞大和复杂, ...

  7. Spring中各个jar包的作用

    spring.jar 是包含有完整发布模块的单个jar 包.但是不包括mock.jar, aspects.jar, spring-portlet.jar, and spring-hibernate2. ...

  8. Spring中事务配置以及事务不起作用可能出现的问题

    前言:在Spring中可以通过对方法进行事务的配置,而不是像原来通过手动写代码的方式实现事务的操作,这在很大程度上减少了开发的难度,本文介绍Spring事务配置的两种方式:基于配置文件的方式和基于注解 ...

  9. (转)web.xml中的contextConfigLocation在spring中的作用

    (转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...

随机推荐

  1. VS2015 C#项目工程配置emgucv依赖的方法

    1.VS2015新建一个C# console工程 2.Tools->NuGet package management->manage NuGet package for solution- ...

  2. React-Native 在android写不支持gif的解决方案!

    只需要在android/app/build.gradle中的dependencies字段中添加: compile 'com.facebook.fresco:animated-gif:0.13.0' 然 ...

  3. 【Spring学习笔记-MVC-2】spring导出Excel

    说明: 1.结合Spring MVC实现Excel导出功能: 2. 在MVC配置文件中配置Excel视图解析器: 需要的jar包 以poi开头的jar包都是必须的 web.xml <?xml v ...

  4. jsoncpp解析拼装数组

    Cocos2d-x添加jsoncpp应该资料都有了,今天来讲讲数组的解析和拼装- int main() { 数组创建与分析: 例子一: string strValue = "{\" ...

  5. 1003 Emergency (25 分)

    1003 Emergency (25 分) As an emergency rescue team leader of a city, you are given a special map of y ...

  6. 批处理-通过mono把c#编译成dll

    ::copyright@cjy @echo off ::mcs.exe address set addrMcs=D:\Program Files\Unity\Editor\Data\MonoBleed ...

  7. python3 string

    字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可.例如: var1 = 'Hello World!' var2 ...

  8. IO流程及优化

    http://blog.csdn.net/xypzwl/article/details/51416883 一.存储设备的存储原理 机械硬盘: 机械硬盘使用磁性物质作为存储介质,用N.S极性来代表0或1 ...

  9. mysql更新(五) 完整性约束 外键的变种 三种关系 数据的增删改

    11-数据的增删改   本节重点: 插入数据 INSERT 更新数据 UPDATE 删除数据 DELETE 再来回顾一下之前我们练过的一些操作,相信大家都对插入数据.更新数据.删除数据有了全面的认识. ...

  10. springboot的一些配置

    spring-boot 1.推荐使用yaml,因为默认的properties需要写更多的前缀 2.使用java -jar 的方式启动jar包的情况下,通过-spring.profiles.actiiv ...