首页 > 使用java注解时不写属性名会给哪个属性赋值

使用java注解时不写属性名会给哪个属性赋值

比如
public @interface RequestMapping {
String name() default "";
.
.
.

}
@RequestMapping(name="xxx",value="xxx")可以理解但是@RequestMapping("/")则不理解到底给谁赋值了,是默认第一个?


默认是给名为"value"的属性赋值。

https://docs.oracle.com/javase/tutorial/java/annotations/basics.html

If there is just one element named value, then the name can be omitted.

【热门文章】
【热门文章】