personinterceptor.java

来自「struts2实例介绍」· Java 代码 · 共 27 行

JAVA
27
字号
package com.test.hibernate;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.test.hibernate.action.LoginAction;

public class PersonInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation vocation) throws Exception {
		if(vocation.getAction() instanceof LoginAction) {
			vocation.invoke();
		}
		ActionContext context = vocation.getInvocationContext();
		Map sessionMap = context.getSession();
		String username = (String)sessionMap.get("username");
		if(username == null || username == "") {
			return "input";
		}
		return vocation.invoke();
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?