网址未随着最新的页面更改而更新 [英] URL not updating with latest page changes

查看:101
本文介绍了网址未随着最新的页面更改而更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与此问题非常相似的问题:

I have a problem that is very similar to this one: How to navigate in JSF? How to make URL reflect current page (and not previous one)

实际上是同样的问题,但是发生在不同的情况下,这就是我使用<jsp:forward>标记的时候

It is actually the same very problem but happens in different situations, and it is when I use a <jsp:forward> tag

为使您处于一种状况,我有一个表格,要求用户并通过以执行登录.这将重定向到执行检查,更新会话的新页面(checklogin.jsp),如果一切正常,则将如下所示:

To put you in situation, I have a form that asks for an user and pass to perform login. This redirects to a new page (checklogin.jsp) that performs the checking, updates the session and if everything is ok then it goes like this:

  if (con.comprobarUserPass(passmd5)) { // We check everything is OK
           sesion.setAttribute("conexion", con);
           sesion.setAttribute("pass", passmd5);
  %>
  <jsp:forward page="index.jsp"/> //forwards to the index
  <%
  } else {
  %>
  <jsp:forward page="login.jsp"> // user/pass error, goes back to the login.jsp page
     <jsp:param name="error" value="<strong><span style=\"color:red;\">Usuario y/o clave incorrectos. <br>Vuelve a intentarlo.</span></strong>"/>
  </jsp:forward>
  <%               }
  } catch (userPassIncorrectoException e) {
  %>
  <jsp:forward page="login.jsp">
     <jsp:param name="error" value="<strong><span style=\"color:red;\">Usuario y/o clave incorrectos. <br>Vuelve a intentarlo.</span></strong>"/>
  </jsp:forward>
  <%                       }
  %>

好吧,即使我已重定向到index.jsp页面或login.jsp页面,但这里的问题仍然存在:

Well, the problem appears here, even if I'm redirected to the index.jsp page or to the login.jsp page my url is:

http://localhost:8084/myContext/checklogin.jsp

有什么想法为什么会这样?这使得调试过程确实比应有的难.

Any ideas why this is happening? It's making the debug process realy harder than it should be.

推荐答案

使用response.sendRedirect("pageToGo");解决了我的问题,并在表单提交和提交后我需要进入的实际页面之间插入了页面.

Solved my problem by using response.sendRedirect("pageToGo"); and inserting a page between the form submit and the actual page I need to go after submitting.

通过这种方式,表单将调用中间网站,该网站仅重定向到用户在提交表单后必须看到的页面.

This way the form will call the intermediary web that only redirects to the page the user has to see after submitting the form.

这篇关于网址未随着最新的页面更改而更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆