⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseaction.java

📁 这是我自己做的一个选课系统
💻 JAVA
字号:
package org.struts2.common;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import org.struts2.util.Constants;
import com.opensymphony.xwork2.ActionContext;

public class BaseAction extends ActionSupport {
	
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// ȡ�õ�ǰ��¼���û���
	protected String getLoginUsername() {
		return (String) ActionContext.getContext().getSession().get(
				Constants.USERNAME_KEY);
	}

	// �жϵ�ǰ�û��Ƿ�ʱ
	protected boolean isTimeout() {
		if (ActionContext.getContext().getSession().get(Constants.USERNAME_KEY) == null) {
			return true;
		} else {
			return false;
		}
	}

	// ���Session�����Ƿ����
	protected boolean isExistSession(String key) {
		if (ActionContext.getContext().getSession().get(key) != null) {
			return true;
		} else {
			return false;
		}
	}

	// ����Session����
	protected void setSession(String key, Object obj) {
		ActionContext.getContext().getSession().put(key, obj);
	}

	// ȡ��Session����
	protected Object getSession(String key) {
		return ActionContext.getContext().getSession().get(key);
	}
	
	// ����һ�����
	protected void saveActionError(String key) {
		super.addActionError(super.getText(key));
	}
	
	// ����һ����Ϣ
	protected void saveActionMessage(String key) {
		super.addActionMessage(super.getText(key));
	}
	
	// ȡ�ò�ѯ��URL
	protected String getRequestPath() {
		return (String)ServletActionContext.getRequest().getServletPath();
	}
}

⌨️ 快捷键说明

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