标签:
原版:http://my.oschina.net/chenhao901007/blog/370109
1.jsp中操作session
(String)request.getSession().getAttribute(
"username"
);
// 获取
request.getSession().setAttribute(
"username"
,
"xxx"
);
// 设置
//servlet中
request.getSession();
session.getAttribute(
"username"
);
session.setAttribute(
"username"
,
"xxx"
);
session.setMaxInactiveInterval(
30
*
60
);
session.invalidate();
//struts中方法1
ServletActionContext.getRequest().getSession().setAttribute(
"username"
,
"xxx"
);
ServletActionContext.getRequest().getSession().getAttribute(
"username"
);
ServletActionContext.getRequest().getSession().setMaxInactiveInterval(
30
*
60
);
ServletActionContext.getRequest().getSession().invalidate();
//struts中方法2
ActionContext.getContext().getSession().put(
"username"
,
"xxx"
);
ActionContext.getContext().getSession().get(
"username"
);
ActionContext.getContext().getSession().clear();
<
session-config
>
<
session-timeout
>30</
session-timeout
>
</
session-config
>
<
session-config
>
<
session-timeout
>30</
session-timeout
>
</
session-config
>
标签:
原文地址:http://www.cnblogs.com/xiaoxiao5ya/p/4773525.html