Java页面重定向 [英] Java page re-direct

查看:99
本文介绍了Java页面重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是首次点击此方法时转到免责声明页面,然后在此之后的任何时间转到其他页面。我目前的方法只是给我免责声明页面。让我知道是否需要更深入的解释...谢谢!!!

What I want to do is go to a disclaimer page when they first initially hit this method, and then any time after that go to a different page. My current method just takes to me the disclaimer page. Let me know if furthur explanation is needed...thanks!!!

public int show(Action action)
throws Exception
{

    HttpServletRequest request = action.getRequest();

action.setJspURI("htemp.jsp");
return FORWARD;
}

基本上我需要在第一次添加一个If去页面命中这个方法我想是这样的:

Basically I need to add an If to go to a page the first time it hits this method I guess like so:

public int show(Action action)
throws Exception
{

    HttpServletRequest request = action.getRequest();
--->> If (FIRST TIME HITTING THE METHOD)  
          {
           go here!!!        
          }  
 action.setJspURI("htemp.jsp");
return FORWARD;
}


推荐答案

当此人点击页面时这是第一次在会话层上抛出一个标志。然后,只要有人来到页面,您就可以检查它是否存在,并相应地重定向它们。唯一的问题是,除非您实施登录系统,否则他们每次访问时都必须同意。

When the person hits the page for the first time, throw a flag on the session layer. Then anytime a person comes to the page you can check to see if it exists or not, and redirect them accordingly. Only problem with that is that they have to agree to it every time they visit unless you implement a login system.

P.S。您应该能够从第一行中获得的请求对象中获取会话。然后在该会话对象上使用setAttribute。

P.S. you should be able to get the Session off of the request object you get in that first line. Then just use setAttribute on that session object.

这篇关于Java页面重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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