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. lamba数据架构以及数据湖

    面试大数据项目,面试过程中发现面试官提到的两个概念没有搞清楚: 1. lamba数据架构:这个概念的提出是由storm的作者提出来的,其实主旨就是想要说明,数据的处理分成三层,一类是批处理程序(bat ...

  2. URL中的hash(井号)

    1.#的含义 #代表网页中的一个位置,其右边的字符,就是该位置的标识符.比如 http://www.example.com/index.html#print 就是代表index.html中的print ...

  3. 蓝桥杯 算法训练 ALGO-116 最大的算式

    算法训练 最大的算式   时间限制:1.0s   内存限制:256.0MB 问题描述 题目很简单,给出N个数字,不改变它们的相对位置,在中间加入K个乘号和N-K-1个加号,(括号随便加)使最终结果尽量 ...

  4. Bootstrap-CSS:网格系统

    ylbtech-Bootstrap-CSS:网格系统 1.返回顶部 1. Bootstrap 网格系统 本章节我们将讲解 Bootstrap 的网格系统(Grid System). Bootstrap ...

  5. Amazon behavior question

    Amazon onsite behavior question[一亩三分地论坛面经版] - Powered by Discuz! http://www.1point3acres.com/bbs/thr ...

  6. VMware vCenter Server安装

    SQL Server 2008 R2安装包:http://blog.sina.com.cn/s/blog_4aedf6370101j9tz.html SQL Server安装指导:http://www ...

  7. 1030 Travel Plan (30 分)

    1030 Travel Plan (30 分) A traveler's map gives the distances between cities along the highways, toge ...

  8. 2015ACM-ICPC长春E题(hdu5531)题解

    一.题意 No response.T_T 二.思路 分$n$为奇数或者偶数讨论. 如果$n$是奇数,列出不等式组:$r_1+r_2=d_{1},r_2+r_3=d_{2},r_3+r_4=d_{3}, ...

  9. jmeter+maven 的简单使用 记录(Windows环境)

    1.手动创建maven工程目录结构,maven对目录结构要求比较严格(pom.xml文件一定要放在根目录下) Maven --src --main --test --jmeter --resource ...

  10. 经典算法 KMP算法详解

    内容: 1.问题引入 2.暴力求解方法 3.优化方法 4.KMP算法 1.问题引入 原始问题: 对于一个字符串 str (长度为N)和另一个字符串 match (长度为M),如果 match 是 st ...