zoukankan      html  css  js  c++  java
  • 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);
            }
        }
    
    }
  • 相关阅读:
    tensorflow之tf.meshgrid()
    Python中数据的保存和读取
    透视投影推导
    tensorflow之tf.slice()
    tensorflow的tf.train.Saver()模型保存与恢复
    偶数分割求平均值
    母牛的故事
    统计一行的不重复的单词字符个数
    N个顶点构成多边形的面积
    贪心法基本入门
  • 原文地址:https://www.cnblogs.com/owenma/p/3469455.html
Copyright © 2011-2022 走看看