【发布时间】:2016-12-30 16:53:05
【问题描述】:
我正在开发一个应用程序,我必须根据用户输入显示来自数据库的数据(假设员工 ID 的字段 empid,我根据此输入显示来自数据库的一些信息)。我正在使用 JSF、PrimeFace 和 Hibernate。
现在我有了 index.xhtml 页面,我在其中输入 empid。之后,我必须重定向到另一个页面 page2.xhtml。
这是 index.xhtml 中的一个 sn-p:
<h:form>
<p>Employee ID:
<p:inputText value="#{userBean.newuser.empid}" required="true"/></p>
</h:form>
<br />
<h:form>
<p:commandButton action="page2?faces-redirect=true" value="Enter" />
</h:form>
但是在重定向到 page2.xhtml 之后,从 index.xhtml 页面输入的 empid 丢失了。我试图阅读一些关于此的帖子,但无法理解。请帮忙。如果是重复的问题,我很抱歉。
【问题讨论】:
-
您的输入框和命令按钮的形式不同?
-
是的,我注意到了。我让它们保持相同的形式,但这也不好。
-
@KorayTugay,您的示例在将参数从 index 转移到 hello 方面效果很好。现在,如果我必须从 hello 转到 hello2.xhtml,有没有办法将 index.xhtml 中的值保存到 hello2.xhtml 中?
标签: java jsf primefaces