在我的 page1.xhtml
<h:form>
<h:inputText value="#{page_one.name}" />
<h:commandButton action="#{page_one.onSubmit}" value="Submit" />
</h:form>
PageOneBean.class
@ManagedBean(name="page_one")
@RequestScoped
public class PageOneBean {
private String name;
public String onSubmit(){
return "/page2.xhtml";
}
}
page2.xhtml
<h:form>
<h:commandButton action="#{page_two.onSubmit}" value="Submit" />
</h:form>
PageTwoBean.class
@ManagedBean(name = "page_two")
@RequestScoped
public class PageTwoBean {
private String name;
public String onSubmit() {
System.out.println("name" + name);
return null;
}
}
当我单击 page_two.onSubmit 按钮时,如何在 pageTwoBean 中获取 pageOneBean.name?