哦,好像是跟 bean 的应用 scope 有关。当去掉 @singleton 后,它变成了 @
Dependent scope, by default. 每次单击,是一个新的请求,产生一个新的 bean
instance, 跟 RequestSope 产生的效果差不多。
ApplicationScoped Specifies that a bean is application scoped.
ConversationScoped Specifies that a bean is conversation scoped.
Dependent Specifies that a bean belongs to the dependent pseudo-scope.
NormalScope Specifies that an annotation type is a normal scope type.
RequestScoped Specifies that a bean is request scoped.
SessionScoped Specifies that a bean is session scoped.
Session Scope: The session scope persists from the time that a session is
established until session termination. A session terminates if the web
application invokes the invalidate method on the HttpSession object, or if
it times out.
RequestScope: The request scope is short-lived. It starts when an HTTP
request is submitted and ends after the response is sent back to the client.
If you place a managed bean into request scope, a new instance is created
with each request. It is worth considering request scope if you are
concerned about the cost of session scope storage.
ApplicationScope: The application scope persists for the entire duration of
the web application. That scope is shared among all requests and all
sessions. You place managed beans into the application scope if a single
bean should be shared among all instances of a web application. The bean is
constructed when it is first requested by any user of the application, and
it stays alive until the web application is removed from the application
server.