本文主要是介绍JSF 2.0/2.1的javax.faces.bean.ViewScoped与JSF 2.2的javax.faces.view.ViewScoped,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
JSF 2.0默认提供的视图范围如下:@javax.faces.bean.NoneScoped
@javax.faces.bean.RequestScoped
@javax.faces.bean.ViewScoped
@javax.faces.flow.FlowScoped
@javax.faces.bean.SessionScoped
@javax.faces.bean.ApplicationScoped
@javax.inject.Named
@javax.faces.bean.ViewScoped
public class AManagedBean {
...
}
所以在JSF 2.0/2.1中,只能如下定义Java类:
@javax.faces.bean.ManagedBean
@javax.faces.bean.ViewScoped
public class AManagedBean {
...
}
为了解决该问题,JSF 2.2提供了额外的javax.faces.view.ViewScoped,以替代javax.faces.bean.ViewScoped(为了向后兼容,同时保留了javax.faces.bean.ViewScoped),从而可以如下定义Java类:
@javax.inject.Named
@javax.faces.view.ViewScoped
public class AManagedBean {
...
}
这篇关于JSF 2.0/2.1的javax.faces.bean.ViewScoped与JSF 2.2的javax.faces.view.ViewScoped的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!