【发布时间】:2015-02-14 12:45:32
【问题描述】:
您好,我在 Glassfish 4.01 上运行的 NetBeans 8.0.2 中有一个 Java EE 7 应用程序
我使用@ManagedBean @SessionScoped作为控制器UserController.java
我有一个index.xhtml Facelet 和一个signup.xhtml Facelet
在index.xhtml Facelet 我有
<h:commandButton value="Sign Up" action="#{userController.signUp()}"></h:commandButton>
在UserController.java中调用函数public String signUp() {
在这个函数中,我返回 return Pages.SIGN_UP_PAGE; 渲染人脸 let signup.xhtml 我有一个表单来填写您的用户数据,例如用户名电子邮件和密码。
第一件事是当我return Pages.SIGN_UP_PAGE; 页面signup.xhtml 被渲染但在URL 中仍然存在.../faces/index.xhtml
在signup.xhtml我有
<h:commandButton value="Create User" action="#{userController.createNewUser()}"></h:commandButton>
然后在public String createNewUser() 函数中,我返回return Pages.USER_ACTION_OVERVIEW;,它呈现页面overview.xhtml,但随后带有URL
.../faces/signup.xhtml
这会导致更大的问题,即当我现在刷新页面(向我显示新已签名用户的数据的概览页面)时,我再次向具有相同 POST 参数的同一用户发送 POST 请求。
我需要的是,如果我呈现页面,则显示正确的 URL(呈现的页面的 on),并且如果我刷新该页面,则不再发送旧的 POST 请求。
【问题讨论】:
-
请查看stackoverflow.com/questions/15521451/…。我认为它回答了你的问题。
标签: jsf jakarta-ee facelets