当前位置: 首页>>代码示例>>Java>>正文


Java SessionMap类代码示例

本文整理汇总了Java中org.apache.struts2.dispatcher.SessionMap的典型用法代码示例。如果您正苦于以下问题:Java SessionMap类的具体用法?Java SessionMap怎么用?Java SessionMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SessionMap类属于org.apache.struts2.dispatcher包,在下文中一共展示了SessionMap类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logout

import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
/**
 * �˳���¼
 */
@SkipValidation
public String logout() {
	// 1����������-1����ȡ������������������>0����-1
	Integer count = (Integer) application.get("count");
	User user = (User) sessionMap.get("user");
	if (count != null && count > 0) {
		count--;
		application.put("count", count);
		// �˳���¼ʱ�Ƴ����û�
		userInfo.remove(user.getUsername());
	}
	//��Cookie�ÿ�
	Cookie emailCookie = new Cookie("email", "");
	Cookie pswCookie = new Cookie("password", "");
	response.addCookie(emailCookie);
	response.addCookie(pswCookie);
	sessionMap.clear();
	// 2��sessionʧЧ��ǿתΪSessionMap������invalidate����
	((SessionMap<String, Object>) sessionMap).invalidate();
	Global.user = null;
	// ֻ�о�̬�������ڵ�¼��ص�֮ǰ��ҳ�棬��Ȼ originUrl ��Ϊnull
	originUrl = request.getHeader("referer");
	originUrl = originUrl.substring(originUrl.lastIndexOf("/")+1);
	return "keepOriginUrl";
}
 
开发者ID:creatorYC,项目名称:yechblog,代码行数:29,代码来源:LoginAction.java

示例2: getStack

import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
public static ValueStack getStack(PageContext pageContext) {
    HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
    ValueStack stack = (ValueStack) req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);

    if (stack == null) {

        HttpServletResponse res = (HttpServletResponse) pageContext.getResponse();
        Dispatcher du = Dispatcher.getInstance();
        if (du == null) {
            throw new ConfigurationException("The Struts dispatcher cannot be found.  This is usually caused by "+
                    "using Struts tags without the associated filter. Struts tags are only usable when the request "+
                    "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.");
        }
        stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
        Map<String, Object> extraContext = du.createContextMap(new RequestMap(req),
                req.getParameterMap(),
                new SessionMap(req),
                new ApplicationMap(pageContext.getServletContext()),
                req,
                res);
        extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);
        stack.getContext().putAll(extraContext);
        req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);

        // also tie this stack/context to the ThreadLocal
        ActionContext.setContext(new ActionContext(stack.getContext()));
    } else {
        // let's make sure that the current page context is in the action context
        Map<String, Object> context = stack.getContext();
        context.put(ServletActionContext.PAGE_CONTEXT, pageContext);

        AttributeMap attrMap = new AttributeMap(context);
        context.put("attr", attrMap);
    }

    return stack;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:38,代码来源:TagUtils.java

示例3: intercept

import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
public String intercept(ActionInvocation invocation) throws Exception {
    HttpSession httpSession = ServletActionContext.getRequest().getSession(false);
    if (httpSession == null) {
        LOG.debug("Creating new HttpSession and new SessionMap in ServletActionContext");
        ServletActionContext.getRequest().getSession(true);
        ServletActionContext.getContext().setSession(new SessionMap<String, Object>(ServletActionContext.getRequest()));
    }
    return invocation.invoke();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:CreateSessionInterceptor.java

示例4: setSession

import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
public void setSession(Map<String, Object> map) {
    userSession = (SessionMap) map;
}
 
开发者ID:sahilsunny,项目名称:ogo,代码行数:4,代码来源:LoginAction.java

示例5: setSession

import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
@Override
public void setSession(Map<String, Object> session) {
	this.session = (SessionMap<String, Object>) session;
}
 
开发者ID:IngloriousCoderz,项目名称:java-web-frameworks,代码行数:5,代码来源:Home.java


注:本文中的org.apache.struts2.dispatcher.SessionMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。