Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道 JSF 框架何时会准确读取 Bean 中提到的注解,何时将它们放入相应的 Maps 中,即 session 、 request 或 application 。
是在服务器启动期间还是在加载相关 JSF 页面时?
只会@ManagedBean(eager=true) @ApplicationScoped在服务器启动期间构建。所有其他都将按需构建(即,当它第一次被访问而所需范围内不存在实例时)。
@ManagedBean(eager=true) @ApplicationScoped
在服务器启动时自动构造请求/视图/会话范围的 bean 没有任何意义,原因很简单,每个 HTTP 请求、视图和会话都应该有自己的实例,而不是在应用程序中与其他人共享。更重要的是,在服务器启动期间,没有任何可用的具体 HTTP 请求或会话。