本文整理汇总了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";
}
示例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;
}
示例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();
}
示例4: setSession
import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
public void setSession(Map<String, Object> map) {
userSession = (SessionMap) map;
}
示例5: setSession
import org.apache.struts2.dispatcher.SessionMap; //导入依赖的package包/类
@Override
public void setSession(Map<String, Object> session) {
this.session = (SessionMap<String, Object>) session;
}