javaWeb-7-Session机制

目录

1、会话机制

2、Cookie机制

2.1 什么是Cookie

3、Session机制

2.1 什么是Session会话

2.2 Session的创建和获取(id号, 是否为新)-项目结构-API全集

2.2.1 编写一个Servlet动态处理器SessionServlet

2.2.2 在web.xml文件中配置Servlet动态处理器的访问路径

2.2.3 编写一个前端测试HTML页面:session.html

2.2.4 HTTP请求测试:Session的创建和获取(id号, 是否为新)

2.3 Session域中数据的存储与获取

2.3.1 第一:编写Servlet处理器

2.3.2 第二:编写前端页面-session.html

2.3.3 第三:在web.xml文件中配置servlet处理器的访问路径

2.3.4 第四:测试与测试结果

2.4 Session生命周期的控制

2.4.1 第一:创建一个Servlet处理器

2.4.2 第二:在web.xml文件中配置访问路径

2.4.3 第三:编写一个前端页面-session.html

2.4.4 第四:测试与结果

2.5 浏览器和Session关联的技术内幕

2.5.1 图解:浏览器和session会话对象在底层是如何关联的

2.5.2 文字:浏览器和session会话对象在底层是如何关联的

1、会话机制

(1)会话:一次会话中包含多次请求和多次响应。注:一次会话,表示浏览器第一次给服务器发送请求,会话建立,直到有一方断开为止,才表示此次会话结束。

(2)功能:在一次会话的多次请求之间是共享数据的。

(3)方式:Cookie:客户端会话技术Session:服务器端会话技术

2、Cookie机制

2.1 什么是Cookie

(1)cookie翻译过来是“饼干”的意思。

(2)cookie是服务器端通知客户端保存键值对的一种客户端会话技术。

(3)客户端有了cookie之后,每次请求都可以把该cookie发送给服务器,在服务器中可以解析该Cookie内容。

(4)每个cookie的大小不能超过4KB。

3、Session机制

2.1 什么是Session会话

(1)Session就是一个接口(HttpSession)。

(2)Session就是一种会话,它是用来维护客户端和服务器端之间相互关联的一种服务端会话技术。

(3)每一个客户端都有一个自己的Session会话。

(4)Session会话当中,我们经常用来保存用户登录的一些信息。

2.2 Session的创建和获取(id号, 是否为新)-项目结构-API全集

(1)如何创建和获取一个Session会话?它们的API都是一样的:request.getSession( );

        1)该方法在第一次调用的时候:是创建一个Session会话。

        2)非第一次调用,也就是之后调用的时候:是获取前面已经创建好的Session会话对象。

(2)那么该如何判断该方法【request.getSession( );】到底是不是第一次调用呢:isNew( ); 用来判断这个Session会话对象到底是不是刚创建出来的,是不是新的。

        1)true:表示这个是刚刚创建的Session对象。

        2)false:表示获取之前已经创建好的Session对象。

(3)每一个Session会话对象都有一个自己的身份证号,也就是ID值。注意:这个ID值是唯一的,使用方法【getId( );】即可获取这个Session对象的会话ID值。

  

2.2.1 编写一个Servlet动态处理器SessionServlet

(1)在动态处理器中写一个创建和获取session的方法:createOrGetSession

package com.wind.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.io.IOException;
import java.lang.reflect.Method;

/**
    //测试1:创建session会话对象和获取session会话对象
 */
public class SessionServlet extends HttpServlet {

    private static final long serialVersionUID = 3312652355957854184L;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解决POST请求中的中文乱码问题,一定要在获取请求参数之前调用才有效
        request.setCharacterEncoding("UTF-8");
        //解决响应中的中文乱码问题
        response.setContentType("text/html; charset=UTF-8");

        String action = request.getParameter("action");
        try {
            //反射方式:获取action业务鉴别字符串,获取相应的业务方法
            Method method = this.getClass().getDeclaredMethod(action, HttpServletRequest.class, HttpServletResponse.class);
            method.invoke(new SessionServlet(), request, response);
        } catch (Exception e) {
            System.out.println("SessionServlet error..." + e);
        }
    }
    
    //测试1:创建session会话对象和获取session会话对象
    private void createOrGetSession(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.创建和获取session会话对象
        HttpSession session = request.getSession();
        //2.判断当前的session会话对象是否是新创建出来的
        boolean aNew = session.isNew();
        //3.获取当前的session会话对象的唯一标识ID值
        String sessionId = session.getId();
        response.getWriter().write("获取了session,它的ID值=" + sessionId + "<br/>");
        response.getWriter().write("这个session是否是新建的=" + aNew + "<br/>");
    }
}

2.2.2 在web.xml文件中配置Servlet动态处理器的访问路径

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>SessionServlet</servlet-name>
        <servlet-class>com.wind.servlet.SessionServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>SessionServlet</servlet-name>
        <url-pattern>/sessionServlet</url-pattern>
    </servlet-mapping>

</web-app>

2.2.3 编写一个前端测试HTML页面:session.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title>Cookie</title>
    <base href="http://localhost:8080/13_cookie_session/">
    <style type="text/css">
        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
<iframe name="target" width="500" height="200" style="..."></iframe>
<div style="...">
    <ul>
        <li><a href="sessionServlet?action=createOrGetSession" target="target">Session的创建和获取(id号是否为新创建)</a></li>
        <li><a href="sessionServlet?action=" target="target">Session域数据的存储</a></li>
        <li><a href="sessionServlet?action=" target="target">Session域数据的获取</a></li>
        <li>Session的生存周期</li>
        <li>
            <ul>
                <li><a href="sessionServlet?action=" target="target">Session的默认超时时间和配置</a></li>
                <li><a href="sessionServlet?action=" target="target">Session的3秒超时销毁</a></li>
                <li><a href="sessionServlet?action=" target="target">Session马上销毁</a></li>
            </ul>
        </li>
        <li><a href="sessionServlet?action=" target="target">浏览器和Session绑定的原理</a></li>
    </ul>
</div>
</body>
</html>

2.2.4 HTTP请求测试:Session的创建和获取(id号, 是否为新)

(1)第一次点击【Session的创建和获取】时,是true。

(2)非第一次点击【Session的创建和获取】时,是false:说明在这个Session会话中,在第一次访问的时候已经创建好了一个服务器和客户端相互联系的Session会话对象,在之后的请求中直接获取并使用它即可。

2.3 Session域中数据的存储与获取

(1)设置值:request.getSession().setAttribute("key1", "value1");

(2)获取值:object = session.getAttribute(name);

2.3.1 第一:编写Servlet处理器

package com.wind.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.io.IOException;
import java.lang.reflect.Method;

/**
    //测试2:Session域数据的存储
    //测试3:Session域数据的获取
 */
public class SessionServlet extends HttpServlet {

    private static final long serialVersionUID = 3312652355957854184L;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解决POST请求中的中文乱码问题,一定要在获取请求参数之前调用才有效
        request.setCharacterEncoding("UTF-8");
        //解决响应中的中文乱码问题
        response.setContentType("text/html; charset=UTF-8");

        String action = request.getParameter("action");
        try {
            //使用反射技术:获取action业务鉴别字符串,获取相应的业务方法
            Method method = this.getClass().getDeclaredMethod(action, HttpServletRequest.class, HttpServletResponse.class);
            method.invoke(new SessionServlet(), request, response);
        } catch (Exception e) {
            System.out.println("SessionServlet error..." + e);
        }
    }

    //测试1:创建session会话对象和获取session会话对象
    private void createOrGetSession(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.创建和获取session会话对象
        HttpSession session = request.getSession();
        //2.判断当前的session会话对象是否是新创建出来的
        boolean aNew = session.isNew();
        //3.获取当前的session会话对象的唯一标识ID值
        String sessionId = session.getId();
        response.getWriter().write("获取了session,它的ID值=" + sessionId + "<br/>");
        response.getWriter().write("这个session是否是新建的=" + aNew + "<br/>");
    }

    //测试2:Session域数据的存储
    private void setAttribute(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.获取Session会话对象
        HttpSession session = request.getSession();
        //2.向Session对象中存储数据
        session.setAttribute("key1", "value1");
        response.getWriter().write("已经向Session中存储了数据<br/>" + session);
    }
    
    //测试3:Session域数据的获取
    private void getAttribute(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.想要从Session对象中获取的值的key
        String name = "key1";
        //2.使用自己编写的Session工具类获取对应的value
        Object attribute = SessionUtils.getAttribute(name, request);
        //3.输出到客户端展示
        response.getWriter().write("从Session对象中已经找到了想要的数据<br/>" + "key=" + name + "value=" + attribute);
    }
}

2.3.2 第二:编写前端页面-session.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title>Cookie</title>
    <base href="http://localhost:8080/13_cookie_session/">
    <style type="text/css">
        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
<iframe name="target" width="500" height="200" style="..."></iframe>
<div style="...">
    <ul>
        <li><a href="sessionServlet?action=createOrGetSession" target="target">Session的创建和获取(id号是否为新创建)</a></li>
        <li><a href="sessionServlet?action=setAttribute" target="target">Session域数据的存储</a></li>
        <li><a href="sessionServlet?action=getAttribute" target="target">Session域数据的获取</a></li>
        <li>Session的生存周期</li>
        <li>
            <ul>
                <li><a href="sessionServlet?action=" target="target">Session的默认超时时间和配置</a></li>
                <li><a href="sessionServlet?action=" target="target">Session的3秒超时销毁</a></li>
                <li><a href="sessionServlet?action=" target="target">Session马上销毁</a></li>
            </ul>
        </li>
        <li><a href="sessionServlet?action=" target="target">浏览器和Session绑定的原理</a></li>
    </ul>
</div>
</body>
</html>

2.3.3 第三:在web.xml文件中配置servlet处理器的访问路径

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>SessionServlet</servlet-name>
        <servlet-class>com.wind.servlet.SessionServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>SessionServlet</servlet-name>
        <url-pattern>/sessionServlet</url-pattern>
    </servlet-mapping>

</web-app>

2.3.4 第四:测试与测试结果

   

    

2.4 Session生命周期的控制

    <!--在web.xml文件中配置了这个属性,表示在当前的web工程中所创建出来的所有Session对象的生命周期都是20分钟-->
    <session-config>
        <session-timeout>20</session-timeout>
    </session-config>

(1)web项目部署成功之后,会有一个项目部署地址:

/Users/c/Library/Caches/IntelliJIdea2018.1/tomcat/Tomcat_8_5_32_spring5-txdemo3-javaWeb_3

(2)在终端中打开该路径,找到路径下的文件web.xml,发现其中已经配置好了该web项目中所有Session的生命周期。

(3)当然了,我们是可以在自己的web项目中根据实际场景来设置这个全局超时时间的:web.xml 文件中配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>SessionServlet</servlet-name>
        <servlet-class>com.wind.servlet.SessionServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>SessionServlet</servlet-name>
        <url-pattern>/sessionServlet</url-pattern>
    </servlet-mapping>

    <!--在web.xml文件中配置了这个属性,表示在当前的web工程中所创建出来的所有Session对象的生命周期都是20分钟-->
    <session-config>
        <session-timeout>20</session-timeout>
    </session-config>

</web-app>

2.4.1 第一:创建一个Servlet处理器

package com.wind.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.io.IOException;
import java.lang.reflect.Method;

/**
    //4.获取Session的默认时长
    //5.设置Session的超时时长=3秒
    //6.设置Session马上销毁
 */
public class SessionServlet extends HttpServlet {

    private static final long serialVersionUID = 3312652355957854184L;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解决POST请求中的中文乱码问题,一定要在获取请求参数之前调用才有效
        request.setCharacterEncoding("UTF-8");
        //解决响应中的中文乱码问题
        response.setContentType("text/html; charset=UTF-8");

        String action = request.getParameter("action");
        try {
            //使用反射技术:获取action业务鉴别字符串,获取相应的业务方法
            Method method = this.getClass().getDeclaredMethod(action, HttpServletRequest.class, HttpServletResponse.class);
            method.invoke(new SessionServlet(), request, response);
        } catch (Exception e) {
            System.out.println("SessionServlet error..." + e);
        }
    }

    //测试1:创建session会话对象和获取session会话对象
    private void createOrGetSession(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.创建和获取session会话对象
        HttpSession session = request.getSession();
        //2.判断当前的session会话对象是否是新创建出来的
        boolean aNew = session.isNew();
        //3.获取当前的session会话对象的唯一标识ID值
        String sessionId = session.getId();
        response.getWriter().write("获取了session,它的ID值=" + sessionId + "<br/>");
        response.getWriter().write("这个session是否是新建的=" + aNew + "<br/>");
    }

    //测试2:Session域数据的存储
    private void setAttribute(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.获取Session会话对象
        HttpSession session = request.getSession();
        //2.向Session对象中存储数据
        session.setAttribute("key1", "value1");
        response.getWriter().write("已经向Session中存储了数据<br/>" + session);
    }

    //测试3:Session域数据的获取
    private void getAttribute(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.想要从Session对象中获取的值的key
        String name = "key1";
        //2.使用自己编写的Session工具类获取对应的value
        Object attribute = SessionUtils.getAttribute(name, request);
        //3.输出到客户端展示
        response.getWriter().write("从Session对象中已经找到了想要的数据<br/>" + "key=" + name + "value=" + attribute);
    }

    //4.获取当前web工程项目中的Session对象的默认时长
    private void defaultLife(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int maxInactiveInterval = request.getSession().getMaxInactiveInterval();
        response.getWriter().write("Session的默认时长=" + maxInactiveInterval + "秒");
    }

    /**
     * Session的超时时长是指:客户端向服务器端发送两次HTTP请求之间的最大的时间间隔。
     * 第二次请求和第一次请求之间的时间间隔,一旦超过了这个超市时长,则第一次请求所创建的Session对象也就被销毁了,
     * 在第二次请求中就需要重新创建一个习的Session会话对象,来维护第二次请求的客户端和服务器端之间的关联关系。
     **/
    //5.设置当前Session的超时时长=3秒
    private void setDestroyTime3Miao(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        session.setMaxInactiveInterval(3);
        response.getWriter().write("设置Session的超时时长=3秒");
    }

    //6.设置当前的Session马上销毁
    private void setDestroyTimeInvalidate(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        session.invalidate();
        response.getWriter().write("设置Session马上销毁");
    }
}

2.4.2 第二:在web.xml文件中配置访问路径

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>SessionServlet</servlet-name>
        <servlet-class>com.wind.servlet.SessionServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>SessionServlet</servlet-name>
        <url-pattern>/sessionServlet</url-pattern>
    </servlet-mapping>

    <!--在web.xml文件中配置了这个属性,表示在当前的web工程中所创建出来的所有Session对象的生命周期都是20分钟-->
    <!--Session的超时:指定是客户端发给服务器两次请求之间的最大的时间间隔-->
    <session-config>
        <session-timeout>20</session-timeout>
    </session-config>

</web-app>

2.4.3 第三:编写一个前端页面-session.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <title>Cookie</title>
    <base href="http://localhost:8080/13_cookie_session/">
    <style type="text/css">
        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
<iframe name="target" width="500" height="200" style="..."></iframe>
<div style="...">
    <ul>
        <li><a href="sessionServlet?action=createOrGetSession" target="target">Session的创建和获取(id号是否为新创建)</a></li>
        <li><a href="sessionServlet?action=setAttribute" target="target">Session域数据的存储</a></li>
        <li><a href="sessionServlet?action=getAttribute" target="target">Session域数据的获取</a></li>
        <li>Session的生存周期</li>
        <li>
            <ul>
                <li><a href="sessionServlet?action=defaultLife" target="target">Session的默认超时时间</a></li>
                <li><a href="sessionServlet?action=setDestroyTime3Miao" target="target">Session的超时时间设置=3秒超时销毁</a></li>
                <li><a href="sessionServlet?action=setDestroyTimeInvalidate" target="target">Session的超时时间是马上销毁</a></li>
            </ul>
        </li>
        <li><a href="sessionServlet?action=" target="target">浏览器和Session绑定的原理</a></li>
    </ul>
</div>
</body>
</html>

2.4.4 第四:测试与结果

    

2.5 浏览器和Session关联的技术内幕

2.5.1 图解:浏览器和session会话对象在底层是如何关联的

2.5.2 文字:浏览器和session会话对象在底层是如何关联的

(1)第一次发送请求:

        (1.1)当客户端,也就是浏览器,第一次向服务器发送请求的时候,是没有任何cookie信息的。此时,在服务器端调用 request.getSession() 方法 是直接创建 一个此次会话的session会话对象。同时,在服务器创建这个session会话对象的时候,都会同时创建一个cookie对象这个cookie对象的key永远是JSESSIONID,value是这个新创建出来的session对象的ID值,也就是说:这个cookie对象和session对象已经绑定了。然后,服务器会通过在响应response对象中存储刚才创建好的cookie数据并吐给客户端,告知客户端去做一些事情。

        (1.2)做哪些事情呢?在浏览器接收到第一次请求的结果之后,会马上在客户端创建一个cookie对象,这个cookie对象中的信息就是刚才从服务器端回传的信息( key是JSESSIONID,value是第一次请求会话时创建的session对象的ID值 )。至此,在客户端就保存了此次会话过程中客户端和服务器端之间的联系了。

        (1.3)注意:这个session会话对象是存储在服务器内存中的,因为一个服务器会有很多客户端去访问,所以服务器内存中会有很多的session会话对象,它们都是用来保存每一个客户端与服务器端之间的会话联系的。

(2)第二次发送请求(在第一次请求结束之后,在不关闭浏览器的情况下发起第二次请求):

        (2.1)因为客户端已经有了cookie对象,所以,在第一次请求之后的后面的不管多少次的HTTP请求,都会在请求头中携带着这个cookie对象发送给服务器。

        (2.2)服务器接收到后面的请求之后,在调用 request.getSession() 方法时,就不是重新创建一个session了,而是直接通过这个cookie对象中的JSESSIONID从服务器内存中寻找之前已经创建好的session对象,找到后 服务器就可以直接使用这个session会话对象了由此可以保证:这些后面的无论多少次的请求,其实和最初的第一次请求 都是属于同一次会话的,使用的全部都是同一个session会话对象,session对象中的数据是这些所有的请求共享的。

(3)第三次发送请求(第二次请求结束之后,先关闭浏览器,然后重新打开浏览器,发起第三次请求):

        (3.1)在第二次请求结束之后,先关闭浏览器,在重新打开浏览器后,再发起第三次HTTP请求,此时,在第一次请求时在客户端创建好的维系本次会话的cookie对象就随着浏览器的关闭而被销毁了,那么第三次客户端发送的请求就会处于无cookie状态,此时服务器接收到第三次请求之后,仍然调用 request.getSession() 方法,会发现客户端并没有携带cookie数据过来,于是,服务器会再次创建一个新的session会话对象来维系客户端和服务器端之间的关联关系,同时,服务器在创建这个新session对象的时候,会同时创建一个新cookie对象,这个新cookie对象的key永远是JSESSIONID,value是这个新session对象的ID值,也就是说:这个新cookie对象和新session对象又绑定在一起了。然后,服务器会通过在响应中存储刚才创建好的新cookie并吐给客户端,告知客户端保存起来。

        (3.2)那么,在浏览器接收到第三次请求的结果后,也会马上在客户端创建一个cookie对象,这个cookie对象中的信息就是刚才从服务器端回传的会话信息( key是JSESSIONID,value是第三次请求创建的新session对象的ID值 )。至此,在客户端就又重新保存了一个新的会话信息,这个新的会话信息维系着第三次请求及其之后的后续请求的客户端和服务器端之间的会话信息(在不关闭浏览器的情况下)。

        (3.3)一旦关闭了浏览器,之前在服务器端创建好的session信息就找不到了,为什么呢?因为在之前创建session对象的同时所创建出的保存在客户端的cookie对象也随着浏览器的关闭而被销毁了,下次客户端发送请求的时候都不会携带cookie数据,自然在服务器端也就找不到之前已经创建好的session对象了。

(4)后面其实就是前面内容的重复了,不再赘述。

猜你喜欢

转载自blog.csdn.net/cmm0401/article/details/111601608
今日推荐