downloadinterceptor.java

来自「有简单的网上书店需求及设计流程」· Java 代码 · 共 42 行

JAVA
42
字号
package org.wiely.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * DowLoadInterceptor implements Interceptor 
 * when the visitors download the resources ,he must be user,or the page
 * is redirect to the index.jsp.
 */
@SuppressWarnings("serial")
public class DownLoadInterceptor implements Interceptor {

	@Override
	public void destroy() {

	}

	@Override
	public void init() {

	}

	@SuppressWarnings("unchecked")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {

		Map session = ActionContext.getContext().getSession();

		if (session.get("user") == null) {
			return "userlogin";
		} else {
			return invocation.invoke();
		}

	}

}

⌨️ 快捷键说明

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