day_05cookie+session+application

本文深入探讨了HTTP协议中的Cookie和Session机制,包括Cookie的基本原理、如何在Java Servlet中设置和读取Cookie,以及Session的工作方式和追踪方法。此外还介绍了如何在浏览器不支持Cookie的情况下使用URL重写实现Session。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

十二月 20, 2015 19:59:17

 

处理cookie

      1.Http协议的无连接性要求一种保存C/S间状态的机制

      2.Coolie:保存到客户端的一个文本文件,与特定客户无关

      3.Cookie以“名--值”对的形式保存数据

      4.创建Cookie:new Cookie(name,value)

      5.可以使用Cookie 的serXXX方法来设定一些相应的值

         5.1 setName(String name)/getName()

         5.2 setValue(String value)/getValue()

         5.3 setMaxAge(int age)/getMaxAge()

         5.4 利用HttpServletResponse的addCookie(Cookie)方法将它设置到客户端

         5.5 利用HttpServletRequest的getCookies()方法来读取客户端的所有的cookie。

 

 

一、cookie原理:

基本原理:

1.服务器可以向客户端写的内容,

2.只能是文本文档

3.客户端可以阻止不让写

4.只能拿自己的webapp写的东西(一个浏览器的标记)

 

     是服务器在本地写的内容,可以进行阻止写入cookie,

在internet选项-->隐私-->高(阻止所有cookie)

 

cookie在本地的地址:

  C盘.....C:\Documents and Settings\Administrator\Cookies

 

Documents and Settings\Administrator\Cookies

 

 

server向client端的cookies;

1.如果设置周期时,写在本地;

2.未设置或者为-1时,是写在client端的内存里;关掉本窗口,就没了。

 

 

 

5.cookie分为两种

    属于窗口/子窗口

    属于文本

6.一个servlet/jsp设置的cookies能够被同一个路径下面或者子路径下面的servlet/jsp读到(路径=url)

(路径!=真实文件路径)

 

二、cookie代码案例

SetCookies.java

import java.io.IOException;
import java.io.PrintWriter; 
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 
/**
 * 设置Cookie到客户端
 * @author jukey
 *
 */
public class SetCookies extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 向客户端写入Cookie,共6个
        for(int i = 0; i < 3; i++) {
            // 3个没设置时间的Cookie,属于本窗口及其子窗口
            Cookie cookie = new Cookie("Session-Cookie-" + i, "Cookie-Value-S" + i);
            response.addCookie(cookie);
            // 以下3个Cookie设置了时间(3600秒,1小时,属于文本,别的窗口也可以访问到这些Cookie
            cookie = new Cookie("Persistent-Cookie-" + i, "Cookie-Value-P" + i);
            cookie.setMaxAge(3600);
            response.addCookie(cookie);
        }
        
        response.setContentType("text/html;charset=gb2312");
        PrintWriter out = response.getWriter();
        String title = "Setting Cookies";
        out.println("<html><head><title>设置Cookie</title></head>"
                + "<body>" + title + "<br>"
                + "There are six cookies associates with this page.<br>"
                + "to see them,visit the <a href=\"ShowCookies\">\n"
                + "<code>ShowCookies</code> servlet</a>"
                + "</body></html>");
    } 
} 

 ShowCookies

import java.io.IOException;
import java.io.PrintWriter; 
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 
/**
 * 读取客户端的Cookies
 */
public class ShowCookies extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        response.setContentType("text/html;charset=gb2312");
        PrintWriter pw = response.getWriter();
        String title = "Active Cookies";
        pw.println("init");
        pw.println("<html><head><title>读取客户端</title></head>"
                + title
                + "\n" + "<table border=1 align=center>\n"
                + "<TH>Cookie Name<TH>Cookie Value" + "<br>");
        
        // 读取客户端的所Cookie
        Cookie[] cookies = request.getCookies();
        if(cookies != null) {
            Cookie cookie;
            for(int i = 0; i < cookies.length; i++) {
                cookie = cookies[i];
                pw.println("<tr>\n" + "<td>" + cookie.getName() +"</td>\n"
                        + "<td>" + cookie.getValue() +"</td></tr>\n");
            }
        }
        pw.println("</table>\n<body><html>");
    } 
} 

 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>ServletLifeCycle</servlet-name>
    <servlet-class>ServletLifeCycle</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>ThreeParams</servlet-name>
    <servlet-class>ThreeParams</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>ShowParameters</servlet-name>
    <servlet-class>ShowParameters</servlet-class>
  </servlet>
  <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>SetCookies</servlet-name>
    <servlet-class>SetCookies</servlet-class>
  </servlet>
  <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>ShowCookies</servlet-name>
    <servlet-class>ShowCookies</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/httpServlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ServletLifeCycle</servlet-name>
    <url-pattern>/ServletLifeCycle</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ThreeParams</servlet-name>
    <url-pattern>/ThreeParams</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ShowParameters</servlet-name>
    <url-pattern>/servlet/ShowParameters</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>SetCookies</servlet-name>
    <url-pattern>/servlet/SetCookies</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ShowCookies</servlet-name>
    <url-pattern>/servlet/ShowCookies</url-pattern>
  </servlet-mapping>
</web-app>

 结果:

本地cookies存在的

Persistent-Cookie-0

Cookie-Value-P0

localhost/TestServlet01/servlet/

1536

1530043264

30489391

4193558928

30489382

*

Persistent-Cookie-1

Cookie-Value-P1

localhost/TestServlet01/servlet/

1536

1530043264

30489391

4193558928

30489382

*

Persistent-Cookie-2

Cookie-Value-P2

localhost/TestServlet01/servlet/

1536

1530043264

30489391

4193558928

30489382

*

 

三、会话跟踪 Session

  3.1 在某段时间一连串客户端与服务器端的交易

  3.2 在Jsp/Servlet中,如果浏览器不支持Cookie,可以通过URL重写来实现,就试讲一些额外数据追加到表示会话的每个URL末尾,

        服务器在该标识符与其存储的有关的该会话的数据之间建立关联。

         如:  hello.jsp?jsessionid=1234

  3.3 可以通过程序来终止一个会话。如果客户端在一定时间内没有操作,服务器会自动终止会话。

  3.3 通过HttpSession来读写Session

 

规则:

   1.如果浏览器支持Cookie,创建Session的还好会把SessionID保存在Cookie里

    2.如果不支持Cookie,必须自己变成使用URL重写的方式实现Session

         2.1 response.encodeURL()

               转码

               URL后面加入SessionId

         2.2Session不像Cookie拥有路径访问的问题

             同一个application下的servet/jsp可以共享同一个session,前提是同一客户端窗口。

 

session是和窗口关联起来的,窗口关了这个sessionid就没了

 

 

 

HttpServletRequest中的Session管理方法

1.getRequestSessionId():

     返回随客户端请求到来的会话ID。可能与当前的会话ID相同,也可能不同。

 2.getSession(boolean isNew): 如果会话已存在一个HttpSession,如果不存在并且isNew()为true,则会创建一个HttpSession。

 3.isRequestedSessionIdFromCookie():当前的session ID如果是从cookie获得,为true。

 4.isRequestedSessionIdValid(): 如果客户端的会话ID代表的是有效会话,则返回true。否则(比如,会话国企或根本不存在),返回false。

 5.HttpSession的常用方法:

     5.1getAtrributeNames()/getAttribute()

     5.2getCreateTime()

     5.3getId()

     5.4 getMaxInactiveInterval()

     5.5invalidate()

     5.6 isNew()

     5.7 setAttribuye()

     5.8 setMaxInactivateInterval() 

 

refresh后jsessionid=45F4C3391CB26DAE6B28C104B6571A12

 

 out.println("<a href=" + response.encodeURL("SessionInfoServlet") + ">refresh</a>");

 

http://localhost:8080/TestServlet01/servlet/SessionInfoServlet;jsessionid=45F4C3391CB26DAE6B28C104B6571A12

 

代码案例

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date; 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; 
/**
 * 演示Servlet API中的session管理机制(常用方法)
 * @author jukey
 *
 */
public class SessionInfoServlet extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        // Returns the current session associated with this request, or if the request does not have a session, creates one. 
        HttpSession mySession = request.getSession(true);
        
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String title = "Session Info Servlet";
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Session Info Servlet</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h3>Session Infomation</h3>");
        
        // Returns true if the client does not yet know about the session or if the client chooses not to join the session. 
        out.println("New Session:" + mySession.isNew() + "<br>");
        // Returns a string containing the unique identifier assigned to this session.
        out.println("Session Id:" + mySession.getId() + "<br>");
        // Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT. 
        out.println("Session Create Time:" + new Date(mySession.getCreationTime()) + "<br>");
        out.println("Session Last Access Time:" + new Date(mySession.getLastAccessedTime()) + "<br>");
        
        out.println("<h3>Request Infomation</h3>");
        // Returns the session ID specified by the client.
        out.println("Session Id From Request:" + request.getRequestedSessionId() + "<br>");
        // Checks whether the requested session ID came in as a cookie. 
        out.println("Session Id Via Cookie:" + request.isRequestedSessionIdFromCookie() + "<br>");
        // Checks whether the requested session ID came in as part of the request URL. 
        out.println("Session Id Via URL:" + request.isRequestedSessionIdFromURL() + "<br>");
        // Checks whether the requested session ID is still valid. 
        out.println("Valid Session Id:" + request.isRequestedSessionIdValid() + "<br>");
        
        out.println("<a href=" + response.encodeURL("SessionInfoServlet") + ">refresh</a>");
        out.println("</body></html>");
        out.close();
    } 
} 

 ShowSession

 

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date; 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; 
/**
 * Session追踪
 * 如果浏览器支持Cookie,创建Session的时候会把SessionId保存在Cookie中
 * 否则必须自己编程使用URL重写的方式实现Session:response.encodeURL()
 * @author jukey
 *
 */ 
public class ShowSession extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        response.setContentType("text/html;charset=gb2312");
        PrintWriter out = response.getWriter();
        String str = "Session Tracking Example";
        String heading;
        
        // 如果会话已经存在,则返回一个HttpSession;否则创建一个新的
        HttpSession session = request.getSession(true);
        // 从当前session中读取属性accessCount的值
        Integer accessCount = (Integer)session.getAttribute("accessCount");
        if(accessCount == null) {
            accessCount = new Integer(0);
            heading = "Welcome newUser";
        } else {
            heading = "Welcome Back";
            accessCount = new Integer(accessCount.intValue() + 1);
        }
        // 向当前session中插入键(key,属性)值(value)对
        // Binds an object to this session, using the name specified.
        session.setAttribute("accessCount", accessCount);
        
        out.println("<html><head><title>Session追踪</title></head>"
                + "<body>" + heading + "<br>"
                + "<h2>Information on Your Session</h2><br>"
                + "\n" + "<table border=1 align=center>\n"
                + "<TH>Info Type<TH>Value" + "<br>"
                + "<tr>\n" + "<td>ID</td>\n"
                + "<td>" + session.getId() +"</td></tr>\n"
                + "<tr>\n" + "<td>CreatTime</td>\n"
                + "<td>" + new Date(session.getCreationTime()) +"</td></tr>\n"
                + "<tr>\n" + "<td>LastAccessTime</td>\n"
                + "<td>" + new Date(session.getLastAccessedTime()) +"</td></tr>\n"
                + "<tr>\n" + "<td>Number of Access</td>\n"
                + "<td>" + accessCount +"</td></tr>\n"
                + "</body></html>");
    } 
} 

 四、Application

4.1 用于保存整个WebApplication的生命周期内都可以访问的数据

4.2 在API中表现为ServletContext

4.3通过HttpServlet的getServletContext方法可以拿到

4.4通过ServletContext的get/setAttribute方法取得/设置相关属性

 

 

http://localhost:8080/TestServlet01/servlet/TestServletContext

 

 

import java.io.IOException;
import java.io.PrintWriter; 
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 
/**
 * Application测试
 * 用于保存整个web应用的生命周期内都可以访问的数据
 * 可供多个不同窗口访问,可作为某一页面被总共访问次数的计数器(比如网站首页的访问量)
 * @author jukey
 *
 */
public class TestServletContext extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        response.setContentType("text/html;charset=gb2312");
        PrintWriter out = response.getWriter();
        
        // Returns a reference to the ServletContext in which this servlet is running. 
        ServletContext application = this.getServletContext();
        // 从当前application中读取属性accessCount的值
        Integer accessCount = (Integer)application.getAttribute("accessCount");
        if(accessCount == null) {
            accessCount = new Integer(0);
        } else {
            accessCount = new Integer(accessCount.intValue() + 1);
        }
        // 向当前application中插入键(key,属性值(value对
        application.setAttribute("accessCount", accessCount);
        
        out.println("<html><head><title>ServletContext测试</title></head><br>"
                + "<body><td>" + accessCount +"</td>\n"
                + "</body></html>");
        
    } 
} 

 web.xml

<servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>TestServletContext</servlet-name>
    <servlet-class>TestServletContext</servlet-class>
  </servlet>
<servlet-mapping>
    <servlet-name>TestServletContext</servlet-name>
    <url-pattern>/servlet/TestServletContext</url-pattern>
  </servlet-mapping>

 

Servlet类本身位于包中的情况 

 

HelloWorldServlet2

http://localhost:8080/TestServlet01/servlet/HelloWorldServlet2

package com.bjsxt.servlet; 
import java.io.IOException;
import java.io.PrintWriter; 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 
/**
 * Servlet类本身位于包中的情况
 * classes中要class文件及其各级目录一起放置
 * web中如下设置:<servlet-class>com.bjsxt.servlet.HelloWorldServlet2</servlet-class>
 * @author jukey
 *
 */
public class HelloWorldServlet2 extends HttpServlet { 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        response.setContentType("text/html;charset=gb2312");
        PrintWriter out = response.getWriter();
        out.println("Hello World!");
        
    } 
} 

 web.xml

 <servlet>
    <description>This is the description of my J2EE component</description>
    <display-name>This is the display name of my J2EE component</display-name>
    <servlet-name>HelloWorldServlet2</servlet-name>
    <servlet-class>com.bjsxt.servlet.HelloWorldServlet2</servlet-class>
  </servlet>
 <servlet-mapping>
    <servlet-name>HelloWorldServlet2</servlet-name>
    <url-pattern>/servlet/HelloWorldServlet2</url-pattern>
  </servlet-mapping>

 星期日, 十二月 20, 2015 22:28:38

MultiValueDictKeyError at /auth/users/ 'password' Request Method: POST Request URL: http://127.0.0.1:8000/auth/users/ Django Version: 4.2.21 Exception Type: MultiValueDictKeyError Exception Value: 'password' Exception Location: C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\datastructures.py, line 86, in __getitem__ Raised during: account.views.UserView Python Executable: C:\Users\高琨\AppData\Local\Programs\Python\Python39\python.exe Python Version: 3.9.11 Python Path: ['C:\\Users\\高琨\\Desktop\\backend', 'C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39', 'C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages'] Server time: Tue, 24 Jun 2025 10:29:49 +0800 Traceback Switch to copy-and-paste view C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\datastructures.py, line 84, in __getitem__ list_ = super().__getitem__(key) … Local vars During handling of the above exception ('password'), another exception occurred: C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py, line 55, in inner response = get_response(request) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py, line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\decorators\csrf.py, line 56, in wrapper_view return view_func(*args, **kwargs) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\rest_framework\viewsets.py, line 124, in view return self.dispatch(request, *args, **kwargs) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\rest_framework\views.py, line 509, in dispatch response = self.handle_exception(exc) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\rest_framework\views.py, line 469, in handle_exception self.raise_uncaught_exception(exc) … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\rest_framework\views.py, line 480, in raise_uncaught_exception raise exc … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\rest_framework\views.py, line 506, in dispatch response = handler(request, *args, **kwargs) … Local vars C:\Users\高琨\Desktop\backend\account\views.py, line 31, in login password = request.data['password'] … Local vars C:\Users\高琨\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\datastructures.py, line 86, in __getitem__ raise MultiValueDictKeyError(key) … Local vars Request information USER AnonymousUser GET No GET data POST Variable Value csrfmiddlewaretoken 'DWg42eYqodHAyGvU8iq7SW01Agw6SWsrGqn2RNRtENkZgyesArpAfiWcxFAkniwR' last_login '' first_name '琨' last_name '高' date_joined '' email '3537676579@qq.com' desc '啊大苏打' mobile '13698551543' gender '' FILES Variable Value avatar <InMemoryUploadedFile: 屏幕截图 2025-05-16 181140.png (image/png)> COOKIES Variable Value csrftoken '********************' META Variable Value ALLUSERSPROFILE 'C:\\ProgramData' APPDATA 'C:\\Users\\高琨\\AppData\\Roaming' CHROME_CRASHPAD_PIPE_NAME '\\\\.\\pipe\\crashpad_2004_IXNEYUSYGSDNGSXV' COLORTERM 'truecolor' COMMONPROGRAMFILES 'C:\\Program Files\\Common Files' COMMONPROGRAMFILES(X86) 'C:\\Program Files (x86)\\Common Files' COMMONPROGRAMW6432 'C:\\Program Files\\Common Files' COMPUTERNAME 'LAPTOP-SUN5G18K' COMSPEC 'C:\\WINDOWS\\system32\\cmd.exe' CONTENT_LENGTH '75110' CONTENT_TYPE 'multipart/form-data; boundary=----WebKitFormBoundaryJGK9BG3i7H6CHnvK' CSRF_COOKIE 'dEh8ZJ3dqKNzS2TICj9Dxw6l7zeoFweA' DJANGO_SETTINGS_MODULE 'core.settings' DRIVERDATA 'C:\\Windows\\System32\\Drivers\\DriverData' EFC_9700_1262719628 '1' EFC_9700_1592913036 '1' EFC_9700_2283032206 '1' EFC_9700_2775293581 '1' EFC_9700_3789132940 '1' FPS_BROWSER_APP_PROFILE_STRING 'Internet Explorer' FPS_BROWSER_USER_PROFILE_STRING 'Default' GATEWAY_INTERFACE 'CGI/1.1' HOMEDRIVE 'C:' HOMEPATH '\\Users\\高琨' HTTP_ACCEPT 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' HTTP_ACCEPT_ENCODING 'gzip, deflate, br, zstd' HTTP_ACCEPT_LANGUAGE 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' HTTP_CACHE_CONTROL 'max-age=0' HTTP_CONNECTION 'keep-alive' HTTP_COOKIE '********************' HTTP_HOST '127.0.0.1:8000' HTTP_ORIGIN 'http://127.0.0.1:8000' HTTP_REFERER 'http://127.0.0.1:8000/auth/users/' HTTP_SEC_CH_UA '"Microsoft Edge";v="137", "Chromium";v="137", "Not/A)Brand";v="24"' HTTP_SEC_CH_UA_MOBILE '?0' HTTP_SEC_CH_UA_PLATFORM '"Windows"' HTTP_SEC_FETCH_DEST 'document' HTTP_SEC_FETCH_MODE 'navigate' HTTP_SEC_FETCH_SITE 'same-origin' HTTP_SEC_FETCH_USER '?1' HTTP_UPGRADE_INSECURE_REQUESTS '1' HTTP_USER_AGENT ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like ' 'Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0') LANG 'zh_CN.UTF-8' LOCALAPPDATA 'C:\\Users\\高琨\\AppData\\Local' LOGONSERVER '\\\\LAPTOP-SUN5G18K' NPM_HOME 'C:\\Program Files\\nodejs\\node_global' NUMBER_OF_PROCESSORS '16' NVM_HOME 'E:\\nvm' NVM_SYMLINK 'C:\\nvm4w\\nodejs' ONEDRIVE 'C:\\Users\\高琨\\OneDrive' ORIGINAL_XDG_CURRENT_DESKTOP 'undefined' OS 'Windows_NT' PATH ('E:\\bin\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Windows\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps;C:\\windows\\system32\\HWAudioDriver\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;E:\\nvm;C:\\nvm4w\\nodejs;C:\\Program ' 'Files\\dotnet\\;C:\\Program Files\\nodejs\\;C:\\Program ' 'Files\\nodejs\\node_global;C:\\Windows\\System32\\node_modules\\yarn\\bin;D:\\yarn_global\\bin;F:\\;C:\\Program ' 'Files ' '(x86)\\Tencent\\微信web开发者工具\\dll;C:\\Users\\高琨\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe;D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts;D:\\phpstudy_pro\\Extensions\\composer2.5.8;C:\\Program ' 'Files (x86)\\NetSarang\\Xftp ' '8\\;C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\;C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Python39\\;C:\\Users\\高琨\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\高琨\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\高琨\\AppData\\Local\\Programs\\Microsoft ' 'VS Code\\bin;E:\\nvm;C:\\nvm4w\\nodejs;C:\\Users\\高琨\\AppData\\Roaming\\npm') PATHEXT '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL' PATH_INFO '/auth/users/' PROCESSOR_ARCHITECTURE 'AMD64' PROCESSOR_IDENTIFIER 'Intel64 Family 6 Model 154 Stepping 3, GenuineIntel' PROCESSOR_LEVEL '6' PROCESSOR_REVISION '9a03' PROGRAMDATA 'C:\\ProgramData' PROGRAMFILES 'C:\\Program Files' PROGRAMFILES(X86) 'C:\\Program Files (x86)' PROGRAMW6432 'C:\\Program Files' PSMODULEPATH ('C:\\Users\\高琨\\Documents\\WindowsPowerShell\\Modules;C:\\Program ' 'Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules') PUBLIC 'C:\\Users\\Public' QUERY_STRING '' REMOTE_ADDR '127.0.0.1' REMOTE_HOST '' REQUEST_METHOD 'POST' RUN_MAIN 'true' SCRIPT_NAME '' SERVER_NAME '127.0.0.1' SERVER_PORT '8000' SERVER_PROTOCOL 'HTTP/1.1' SERVER_SOFTWARE 'WSGIServer/0.2' SESSIONNAME 'Console' SYSTEMDRIVE 'C:' SYSTEMROOT 'C:\\WINDOWS' TEMP 'C:\\Users\\高琨\\AppData\\Local\\Temp' TERM_PROGRAM 'vscode' TERM_PROGRAM_VERSION '1.101.1' TMP 'C:\\Users\\高琨\\AppData\\Local\\Temp' USERDOMAIN 'LAPTOP-SUN5G18K' USERDOMAIN_ROAMINGPROFILE 'LAPTOP-SUN5G18K' USERNAME '高琨' USERPROFILE 'C:\\Users\\高琨' VSCODE_INJECTION '1' VSCODE_NONCE '71bb0211-da42-4580-bb3d-e761a3af6e04' VSCODE_STABLE '1' WINDIR 'C:\\WINDOWS' ZES_ENABLE_SYSMAN '1' wsgi.errors <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'> wsgi.file_wrapper <class 'wsgiref.util.FileWrapper'> wsgi.input <django.core.handlers.wsgi.LimitedStream object at 0x000001EBE9AE46D0> wsgi.multiprocess False wsgi.multithread True wsgi.run_once False wsgi.url_scheme 'http' wsgi.version (1, 0) Settings Using settings module core.settings Setting Value ABSOLUTE_URL_OVERRIDES {} ADMINS [] ALLOWED_HOSTS ['*'] APPEND_SLASH True AUTHENTICATION_BACKENDS ['django.contrib.auth.backends.ModelBackend'] AUTH_PASSWORD_VALIDATORS '********************' AUTH_USER_MODEL 'account.User' BASE_DIR WindowsPath('C:/Users/高琨/Desktop/backend') CACHES {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS 'default' CACHE_MIDDLEWARE_KEY_PREFIX '********************' CACHE_MIDDLEWARE_SECONDS 600 CORS_ALLOW_ALL_ORIGINS True CSRF_COOKIE_AGE 31449600 CSRF_COOKIE_DOMAIN None CSRF_COOKIE_HTTPONLY False CSRF_COOKIE_MASKED False CSRF_COOKIE_NAME 'csrftoken' CSRF_COOKIE_PATH '/' CSRF_COOKIE_SAMESITE 'Lax' CSRF_COOKIE_SECURE False CSRF_FAILURE_VIEW 'django.views.csrf.csrf_failure' CSRF_HEADER_NAME 'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS [] CSRF_USE_SESSIONS False DATABASES {'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_HEALTH_CHECKS': False, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.sqlite3', 'HOST': '', 'NAME': WindowsPath('C:/Users/高琨/Desktop/backend/db.sqlite3'), 'OPTIONS': {}, 'PASSWORD': '********************', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': ''}} DATABASE_ROUTERS [] DATA_UPLOAD_MAX_MEMORY_SIZE 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS 1000 DATA_UPLOAD_MAX_NUMBER_FILES 100 DATETIME_FORMAT 'N j, Y, P' DATETIME_INPUT_FORMATS ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M'] DATE_FORMAT 'N j, Y' DATE_INPUT_FORMATS ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] DEBUG True DEBUG_PROPAGATE_EXCEPTIONS False DECIMAL_SEPARATOR '.' DEFAULT_AUTO_FIELD 'django.db.models.BigAutoField' DEFAULT_CHARSET 'utf-8' DEFAULT_EXCEPTION_REPORTER 'django.views.debug.ExceptionReporter' DEFAULT_EXCEPTION_REPORTER_FILTER 'django.views.debug.SafeExceptionReporterFilter' DEFAULT_FILE_STORAGE 'django.core.files.storage.FileSystemStorage' DEFAULT_FROM_EMAIL 'webmaster@localhost' DEFAULT_INDEX_TABLESPACE '' DEFAULT_TABLESPACE '' DISALLOWED_USER_AGENTS [] EMAIL_BACKEND 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST 'localhost' EMAIL_HOST_PASSWORD '********************' EMAIL_HOST_USER '' EMAIL_PORT 25 EMAIL_SSL_CERTFILE None EMAIL_SSL_KEYFILE '********************' EMAIL_SUBJECT_PREFIX '[Django] ' EMAIL_TIMEOUT None EMAIL_USE_LOCALTIME False EMAIL_USE_SSL False EMAIL_USE_TLS False FILE_UPLOAD_DIRECTORY_PERMISSIONS None FILE_UPLOAD_HANDLERS ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler'] FILE_UPLOAD_MAX_MEMORY_SIZE 2621440 FILE_UPLOAD_PERMISSIONS 420 FILE_UPLOAD_TEMP_DIR None FIRST_DAY_OF_WEEK 0 FIXTURE_DIRS [] FORCE_SCRIPT_NAME None FORMAT_MODULE_PATH None FORM_RENDERER 'django.forms.renderers.DjangoTemplates' IGNORABLE_404_URLS [] INSTALLED_APPS ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'corsheaders', 'account'] INTERNAL_IPS [] LANGUAGES [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ar-dz', 'Algerian Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('ckb', 'Central Kurdish (Sorani)'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('hy', 'Armenian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('ig', 'Igbo'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('ky', 'Kyrgyz'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('ms', 'Malay'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('tg', 'Tajik'), ('th', 'Thai'), ('tk', 'Turkmen'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('uz', 'Uzbek'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')] LANGUAGES_BIDI ['he', 'ar', 'ar-dz', 'ckb', 'fa', 'ur'] LANGUAGE_CODE 'zh-hans' LANGUAGE_COOKIE_AGE None LANGUAGE_COOKIE_DOMAIN None LANGUAGE_COOKIE_HTTPONLY False LANGUAGE_COOKIE_NAME 'django_language' LANGUAGE_COOKIE_PATH '/' LANGUAGE_COOKIE_SAMESITE None LANGUAGE_COOKIE_SECURE False LOCALE_PATHS [] LOGGING {} LOGGING_CONFIG 'logging.config.dictConfig' LOGIN_REDIRECT_URL '/accounts/profile/' LOGIN_URL '/accounts/login/' LOGOUT_REDIRECT_URL None MANAGERS [] MEDIA_ROOT 'C:/Users/高琨/Desktop/backend/media' MEDIA_URL '/media/' MESSAGE_STORAGE 'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE ['corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] MIGRATION_MODULES {} MONTH_DAY_FORMAT 'F j' NUMBER_GROUPING 0 PASSWORD_HASHERS '********************' PASSWORD_RESET_TIMEOUT '********************' PREPEND_WWW False REST_FRAMEWORK {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',), 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'DEFAULT_PERMISSION_CLASSES': 'rest_framework.permissions.IsAuthenticated', 'NON_FIELD_ERRORS_KEY': '********************', 'PAGE_SIZE': 3} ROOT_URLCONF 'core.urls' SECRET_KEY '********************' SECRET_KEY_FALLBACKS '********************' SECURE_CONTENT_TYPE_NOSNIFF True SECURE_CROSS_ORIGIN_OPENER_POLICY 'same-origin' SECURE_HSTS_INCLUDE_SUBDOMAINS False SECURE_HSTS_PRELOAD False SECURE_HSTS_SECONDS 0 SECURE_PROXY_SSL_HEADER None SECURE_REDIRECT_EXEMPT [] SECURE_REFERRER_POLICY 'same-origin' SECURE_SSL_HOST None SECURE_SSL_REDIRECT False SERVER_EMAIL 'root@localhost' SESSION_CACHE_ALIAS 'default' SESSION_COOKIE_AGE 1209600 SESSION_COOKIE_DOMAIN None SESSION_COOKIE_HTTPONLY True SESSION_COOKIE_NAME 'sessionid' SESSION_COOKIE_PATH '/' SESSION_COOKIE_SAMESITE 'Lax' SESSION_COOKIE_SECURE False SESSION_ENGINE 'django.contrib.sessions.backends.db' SESSION_EXPIRE_AT_BROWSER_CLOSE False SESSION_FILE_PATH None SESSION_SAVE_EVERY_REQUEST False SESSION_SERIALIZER 'django.contrib.sessions.serializers.JSONSerializer' SETTINGS_MODULE 'core.settings' SHORT_DATETIME_FORMAT 'm/d/Y P' SHORT_DATE_FORMAT 'm/d/Y' SIGNING_BACKEND 'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS [] SIMPLE_JWT {'ACCESS_TOKEN_LIFETIME': '********************', 'AUTH_HEADER_TYPES': ('Bearer',), 'REFRESH_TOKEN_LIFETIME': '********************', 'SIGNING_KEY': '********************'} STATICFILES_DIRS [] STATICFILES_FINDERS ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_ROOT 'C:\\Users\\高琨\\Desktop\\backend\\static' STATIC_URL '/static/' STORAGES {'default': {'BACKEND': 'django.core.files.storage.FileSystemStorage'}, 'staticfiles': {'BACKEND': 'django.contrib.staticfiles.storage.StaticFilesStorage'}} TEMPLATES [{'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}}] TEST_NON_SERIALIZED_APPS [] TEST_RUNNER 'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR ',' TIME_FORMAT 'P' TIME_INPUT_FORMATS ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'] TIME_ZONE 'Asia/Shanghai' USE_DEPRECATED_PYTZ False USE_I18N True USE_L10N True USE_THOUSAND_SEPARATOR False USE_TZ False USE_X_FORWARDED_HOST False USE_X_FORWARDED_PORT False WSGI_APPLICATION 'core.wsgi.application' X_FRAME_OPTIONS 'DENY' YEAR_MONTH_FORMAT 'F Y'
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值