Session 使用

Session是在服务器端创建的:

HttpSession session = request.getSession();

设置session里面的值:

session.setAttribute("code", "值");

取得session里面的值;

String code =  session.getAttribute("code");

判断是否已经创

        if (session.isNew()) {

             response.getWriter().print("session创建成功,session的id是:"+sessionId);

         }else {

             response.getWriter().print("服务器已经存在该session了,session的id是:"+sessionId);

         }

猜你喜欢

转载自star77266989.iteye.com/blog/2242346
今日推荐