我看到一个问题,看起来像这样:
public @interface Controller {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
*/
String value() default "";
}
什么是默认关键字,默认情况下为“”?
答案 0 :(得分:1)
Java中的注释可能包含属性,在您的情况下,@Controller
注释具有名为String
的(value
)属性。
使用注释时,您可能会省略为属性设置特定值,然后将使用默认值。例如:
@Controller //<-- here the value is `""`
public class SomeController { }
@Controller("other") //<-- but here value is set to "other"
public class OtherController { }