Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf @ManagedProperty和FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(";bean";)之间的差异_Jsf_Managed Property_Externalcontext - Fatal编程技术网

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");
}