当按下backbutton或F5时,如何在托管bean上调用方法?
If the bean is request scoped and the page is served with response headers which instructs the browser to not cache the page, then you can do that job in the bean's constructor or @PostConstruct
method.
Eg
public class Bean {
public Bean() {
// Here, in the constructor.
}
@PostConstruct
public void init() {
// Or here, in the postconstructor.
}
}
The @PostConstruct
method is particularly useful if you're injecting dependencies by @ManagedProperty
, @EJB
or @Inject
, etc and want to do the initialization job based on those dependencies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.