Jsf @ManagedProperty和FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(";bean";)之间的差异
这两者之间的区别是什么:Jsf @ManagedProperty和FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(";bean";)之间的差异,jsf,managed-property,externalcontext,Jsf,Managed Property,Externalcontext,这两者之间的区别是什么: public class GameController implements Serializable{ @ManagedProperty(value="#{Gamebean}") private Game game; 及 如果没有区别,什么方法更好? 干杯 如果bean还不存在,@ManagedProperty方法将自动创建bean。如果bean不是预先(自动)创建的,则getSessionMap() 以最少的努力和顾虑达到同样效果的代码更好。感谢您的回复:D p
public class GameController implements Serializable{
@ManagedProperty(value="#{Gamebean}")
private Game game;
及
如果没有区别,什么方法更好?
干杯 如果bean还不存在,
@ManagedProperty
方法将自动创建bean。如果bean不是预先(自动)创建的,则getSessionMap()
以最少的努力和顾虑达到同样效果的代码更好。感谢您的回复:D
public class GameController implements Serializable{
private Game game;
public GameController(){
game =(Game)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("Gamebean");
}