session

原文:http://my.oschina.net/chenhao901007/blog/370109
java中操作session

//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();
web.xml中操作session
<session-config>  
    <session-timeout>30</session-timeout>  
</session-config>
 

posted on 2016-05-23 10:46  糖+少了  阅读(118)  评论(0)    收藏  举报

导航