struts2中的使用BaseAction获取Session

package com.owen.ma;

import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware; import com.opensymphony.xwork2.ActionSupport; public class BaseAction extends ActionSupport implements RequestAware , SessionAware { private Map<string, object=""> request;
private Map<string, object=""> session; @Override
public void setRequest(Map<string, object=""> request) {
this.request = request;
} @Override
public void setSession(Map<string, object=""> session) {
this.session = session;
} public Object getAttribute(String key) {
if (this.request.containsKey(key)) {
return this.request.get(key);
}
return null;
} public void setAttribute(String key, Object object) {
if (this.request.containsKey(key)) {
this.request.remove(key);
this.request.put(key, object);
}
} public Object getSession(String key) {
if (this.session.containsKey(key)) {
return this.session.get(key);
}
return null;
} public void setSession(String key, Object object) {
if (this.session.containsKey(key)) {
this.session.remove(key);
this.session.put(key, object);
}
} }
上一篇:glctx.ClearColor 参数说明


下一篇:RHEL 5 安装phpqrcode生成二维码