我在 django python 中有一个后端应用程序,它在 http://localhost:8000 上提供服务。
我有一个 angular 前端,它在 http://localhost:4200 上提供服务。
我在 Django 上禁用了 CORS。在 http://localhost:8000/auth/login/ 上点击登录 api 时,我收到了一个有效的响应以及 Set-Cookie 标头。

这是我打印 cookie 的角度代码:
this.http.post<any>('http://localhost:8000/auth/login/', this.LoginForm, { observe: 'response' }).subscribe(response => {
console.log("response is ", response);
var cookies = this.cookieService.getAll();//('cookies');
console.log("cookies is :", cookies);
Run Code Online (Sandbox Code Playgroud)
它在控制台上打印一个空对象。我如何使这项工作?我想使用 cookie 进行身份验证。
我使用菜单在eclipse版本:Kepler Service Release 1中创建了一个动态Web应用程序.之后,我使用configure - > convert to maven project将其转换为maven项目.然后我做了maven->添加依赖,然后搜索log4j.
在将鼠标悬停在log4j的标记上添加后,它会显示Missing artifact log4j:log4j:bundle:1.2.17.我无法使用maven更新依赖项.怎么解决?还请解释错误原因.
这是添加log4j后生成的xml.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Healthcare</groupId>
<artifactId>Healthcare</artifactId>
<version>0.0.1-HEALTHCARE</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>bundle</type>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud) 我想接受一个参数并创建一个名称为参数本身的类。例如,我以“Int”为参数,创建了一个名为“Int”的类,我的类就是这样的。
class Int :
def __init__(self,param) :
self.value = 3
Run Code Online (Sandbox Code Playgroud)
我就是这样做的。
def makeClass( x ) :
return eval( 'class %s :\n def __init__(self,param) :\n self.type = 3'%(x,))
Run Code Online (Sandbox Code Playgroud)
然后打电话
myClass = makeClass('Int')
myInt = myClass(3)
Run Code Online (Sandbox Code Playgroud)
我收到了一个语法错误。请帮忙。
为n计算此函数的时间复杂度是多少?
int rec(int n)
{
if (n<=1) {
return n ;
}
int i;
int sum=0;
for (i=1; i<n; i++) {
sum=sum+rec(i);
}
return sum ;
}
Run Code Online (Sandbox Code Playgroud)