判断页面是否登陆或过期

news/2024/7/5 1:08:17
判断页面是否登陆或过期  <script type="text/javascript">var stattitle='判断页面是否登陆或过期 [原]';</script>

public abstract class MyBasePage extends BasePage implements
  PageValidateListener {

 /* 
  * 判断session是否清空,如果为空则跳到提示页面
  * @see org.apache.tapestry.event.PageValidateListener#pageValidate(org.apache.tapestry.event.PageEvent)
  */
 public void pageValidate(PageEvent event) {
  Visit visit = (Visit) getVisit();

  if (visit != null)
   return;
  throw new PageRedirectException("SessionTimeOut" ;
 }
}

然后自己所写的类继承MyBasePage,而不是BasePage,不过记住注销方法里面需要设置visit=null


import javax.servlet.http.HttpSession;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.BaseEngine;

public class MyEngine extends BaseEngine {
private static org.apache.log4j.Logger logger = org.apache.log4j.LogManager
.getLogger(MyEngine.class.getName());

private static final long serialVersionUID = -628778836971125385L;

private transient boolean killSession; //是否要进行session注销操作,默认为false

// public String getStaleSessionPageName() {
// return "Home";
// }

/** 下面的方法用于注销用户 */

protected void cleanupAfterRequest(IRequestCycle cycle) {

super.cleanupAfterRequest(cycle);
if (killSession) {
try {
HttpSession session = cycle.getRequestContext().getSession();
if (session != null) {
session.invalidate();
logger.debug("注销用户" ;
}
} catch (IllegalStateException ex) {

}
}
}

public void logout() {
killSession = true;
Visit visit = (Visit) this.getVisit();
if (visit != null) {
visit.setAppKey(null);
visit.setBnetid(null);
visit.setCalledUserIdList(null);
visit.setIsadmin(false);
visit.setCalledUserIdList(null);
visit.setIsSet(false);
visit.setRole(0);
visit.setRulePriority(null);
visit.setSeluserid(null);
visit.setTupttosave(null);
visit.setUserEmail(null);
visit.setUserid(null);
visit.setUsername(null);
}

}

}
 

http://www.niftyadmin.cn/n/1995601.html

相关文章

Socket 和 SignalR WS WSS

HTML5 WebSocket ASP.NET Core 中的 WebSocket 支持 WS: WebSocket WSS: WebSocket Secure WS是非安全的&#xff0c;WSS是安全的。非安全的没有证书&#xff0c;安全的需要SSL证书。 WS的体现形式是TCP WS AS WS &#xff0c;WSS的体现形式是TCP TLS WS AS WSS。 WS一般默认…

Python中tuple类型的参数只有一个元素时,要加逗号

比如说传入的参数是这样的&#xff08;12&#xff09;&#xff0c;那Python解释器就会把这个参数当成是数字&#xff0c;必须加上逗号才行&#xff0c;即&#xff08;12&#xff0c;&#xff09;Python解释器才会把这个参数当成是元组类型的。

使用WinSock2 SPI进行网络控制访问内容

使用WinSock2 SPI进行网络控制访问内容 baidubaidu编者按&#xff1a;与传统的包过滤防火墙技术不同&#xff0c;本文从应用层网关技术入手&#xff0c;深入探讨了利用WinSock2 SPI进行网络内容访问控制的问题。这是网络安全的一项新内容&#xff0c;或者说&#xff0c;它为网络…

Tapestry的数据校验功能

Tapestry的数据校验功能 数据校验是Web应用的一个很重要的功能。tapestry支持配置式的数据校验&#xff0c;通过使用Delegate、FieldLabel和TextField对数据的显示进行修饰。在page文件中对各输入数据的校验规则进行配置。可以使用系统提供的Validator。出错信息也提供了多种…

HashMap源码解析(jdk1.7)

HashMap源码解析初始化信息添加元素删除元素查找元素containsKey&#xff1a;指定的key是否在HashMap中containsValue&#xff1a;查找HashMap中是否有指定的valueisEmptyindexFor&#xff1a;返回h在table数组中的位置写在后面初始化信息 //HashMap的初始容量&#xff0c;必须…

ZwQueryInformationFile 函数

ZwQueryInformationFile 函数The ZwQueryInformationFile routine returns various kinds of information about a given file object. NTSTATUS ZwQueryInformationFile( IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FileInformatio…

Tapestry在静态页面和动态内容分工方面的研究

Tapestry在静态页面和动态内容分工方面的研究 Tapestry的一个最耀眼的功能是其绝好的模板设计思想&#xff0c;它能够将动态内容以极少的侵入性而展现到HTML页面上&#xff0c;我对其这一功能非常赞赏&#xff0c;如果 Tapestry能够像Spring那样把这一部分HTML模板解析功能独立…

java树形菜单制作

java树形菜单制作用到的技术代码实现用到的技术 SpringMVCSpringmybatiseasyui 代码实现 dto&#xff08;适用于easyui的实体类&#xff09; package com.grand.orgn.dto;import java.util.HashMap; import java.util.Map;/*** * author * 适用于easyUI树形结构的实体类* d…