@RequestParam注解中,defaultValue属性的默认值

无聊水一水,程序员们自己找乐子的方式真的层出不穷

/**
	 * The default value to use as a fallback when the request parameter is
	 * not provided or has an empty value.
	 * 

Supplying a default value implicitly sets {@link #required} to * {@code false}. */ String defaultValue() default ValueConstants.DEFAULT_NONE;

@RequestParam这个注解大家应该很熟悉,其中defaultValue属性用来定义一个参数的自定义属性,不知道大家注意过没有,defaultValue是有自己的默认值的,就是上面这个ValueConstants.DEFAULT_NONE。这个值的属性是一段无意义的16位Unicode码,

/**
	 * Constant defining a value for no default - as a replacement for
	 * {@code null} which we cannot use in annotation attributes.
	 * 

This is an artificial arrangement of 16 unicode characters, * with its sole purpose being to never match user-declared values. * @see RequestParam#defaultValue() * @see RequestHeader#defaultValue() * @see CookieValue#defaultValue() */ String DEFAULT_NONE = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";

大概的意思就是,这个取值的唯一意义就是为了不跟程序中的任何值重复

你可能感兴趣的:(spring)