小编Val*_*jon的帖子

如何在Django中禁用某些视图的SECURE_SSL_REDIRECT?

我有一个网站,我想SECURE_SSL_REDIRECT = True为大多数视图设置,但有一个视图,我需要禁用SSL(用于与不支持它的客户端程序进行通信).

我可以为不需要SSL的视图创建一个全新的Django项目,但必须有一种更简单的方法来管理它.

如何有选择地关闭SSL重定向?

python django ssl https web-services

3
推荐指数
1
解决办法
2188
查看次数

Chrome 上的每个其他 ajax 请求都需要 10 倍的时间

我使用 javascript 发送大量 http 请求,在 chrome 中,第一个请求将花费大约 30 毫秒,第二个请求将花费大约 300 毫秒。无论我提出什么样的请求,后续请求都将在这两个请求之间交替。这在 Firefox 中不会发生。我应该注意到我正在我的计算机上运行开发服务器。谁能解释一下这种情况?

以下是 chrome 计时选项卡的图片:

连接1

连接2

正如您所看到的,连接 2 中有一个非常大的间隙。

javascript ajax google-chrome

3
推荐指数
1
解决办法
459
查看次数

升级到 Spring Boot 2.2.2.RELEASE + Thymeleaf 3.0.11.RELEASE,thymeleaf/layout 停止工作

将 Spring-Boot 从 迁移1.5.3.RELEASE到 后2.2.2.RELEASE,Thymeleaf 停止工作。

pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.2.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

...

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我已经按照Thymeleaf 3 迁移指南+ 阅读Spring-Boot 版本,但没有成功......

模板片段(Thymeleaf 3.0 layout:decorate

<!DOCTYPE html>
<html th:lang="${#locale}" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="https://www.thymeleaf.org"
    xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
    xmlns:layout="https://www.ultraq.net.nz/thymeleaf/layout"
    layout:decorate="layout">
<head>
<title></title>
</head>
<body>
    <div layout:fragment="content">
Run Code Online (Sandbox Code Playgroud)

http://localhost/index 路径比较:

代码片段(1.5.3.RELEASE)

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>

    <title>APLLICATION</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'/><![endif]--> …
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf spring-boot

3
推荐指数
1
解决办法
1008
查看次数

如何在mongodb中使用聚合实现不区分大小写的排序(3.4)

我正在尝试在 MongoDB 中实现排序。但我遇到一个问题,我的排序首先包括大写字母 AZ 文本,然后是小写字母。我不想要他们。我希望排序独立于案例。这是我的查询,

var partnerCollection = [
      from: "courses",
      localField: "_id",
      foreignField: "partnerId",
      as: "courses"
    } },
    {
        $project:
        {
            "_id":1,
            "partnerName":1,
            "phone":1,
            "email":1,
            "courses.courseName": 1,
            "courses.courseType":1,
        }
    },
    {
        $match: findUserDataCondition
    },
    { $sort: { "partnerName" : 1 } },
    { $skip: start },
    { $limit: length }
];
Run Code Online (Sandbox Code Playgroud)

如果我用 PartnerName 排序,我得到的结果为 ABC, DEF, EFG , bcd, cde

我的预期结果是 ABC、bcd、cde、DEF、EFG。请帮助我解决这个问题

sorting mongodb aggregation-framework

3
推荐指数
1
解决办法
2831
查看次数

在Java中解析JSON Map时出现NullPointer异常

我正在尝试在REST API中从下面的JSON解析productId,名称和价格-但是尝试获取他时我得到了空指针异常name- String name = (String) obj.get("name");,我可以知道我在做什么错吗?

任何帮助将非常感激。谢谢!

JSON:

{
    "id": "af0b86eb-046c-4400-8bc4-0e26042b8f53",
    "products": [{
            "productId": "1234",
            "name": "apple",
            "price": "383939"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

Controller.java

public ResponseEntity<Object> create(@RequestBody Map<String, Object> obj) {
    Product response = myservice.create(obj);
    return new ResponseEntity<Object>(response, HttpStatus.CREATED);
}
Run Code Online (Sandbox Code Playgroud)

Service.java

public Product create(Map<String, Object> obj) { 
    for (Entry<String, Object> entry : obj.entrySet()) {
        System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());
    }       

    Object [] products = (Object[]) obj.get("products");
    HashMap <String, Object> productOne …
Run Code Online (Sandbox Code Playgroud)

java json hashmap

2
推荐指数
1
解决办法
110
查看次数

如何从 MongoDB 聚合中的不同集合添加多个 $match 条件

我有 2 个不同的 MongoDB 集合 -员工部门都包含共同的deptid。我想加入这两个集合并从两个集合中添加多个 $match 条件。

雇员:

{
    Empid: 001
    Name: "John"
    Age: 41
    Location: "Belfast"
    deptid: "D101"
}
Run Code Online (Sandbox Code Playgroud)

部门:

{
    deptID: "D101"
    deptNM: "HR"
    deptPr: "O"
}
Run Code Online (Sandbox Code Playgroud)

询问:

db.getCollection('Employees').aggregate([
    { $match:{
        deptNM: "HR",
        Age : {$gt: 40}
       }
    },
    { $lookup: {
        from: "Dept",
        localField: "deptid",
        foreignField: "deptID",
        as: "HR EMP"
        }
     },
     { $project: {
         Empid: 1, Name: 1, Location: 1, deptNM: 1, deptPr: 1
         }
     }
])
Run Code Online (Sandbox Code Playgroud)

上面的查询不起作用,还有其他方法吗?

join match mongodb aggregation-framework

2
推荐指数
1
解决办法
1019
查看次数

将 Spring Boot 从 2.4.1 升级到 2.6.1,出现 `java.time.Instant` 默认不支持错误

当我将 Spring Boot 应用程序从 2.4.1 升级到 2.6.1 时。我收到以下错误。

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:java.time.Instant默认情况下不支持 Java 8 日期/时间类型:添加模块“com.fasterxml.jackson.datatype:jackson-datatype-jsr310”以启用处理(通过引用链:org. springframework.boot.actuate.trace.http.HttpTrace[“时间戳”])

java spring fasterxml spring-boot

2
推荐指数
1
解决办法
3301
查看次数

确定 SDL_surface 的宽度/高度的 SDL_function?

我想制作一个包含 SDL_Surface 、 SDL_Rect 、表面宽度和高度的结构,

这是原型:

typedef struct wall wall;

struct wall {
    SDL_Surface *wall;
    SDL_Rect  wallpos;
    int x;             
    int y;
};
Run Code Online (Sandbox Code Playgroud)

问题是我不想手动生成 wall.x 和 wall.y。

是否有任何 SDL_function 可以根据加载的图像的尺寸确定 SDL_surface 的宽度/高度?

c struct sdl

1
推荐指数
1
解决办法
2202
查看次数

hasOwnProperty 不起作用

{error:true}我从服务器获得了一个 JSON 对象 ( )。

我尝试检查对象是否包含键“error”,并且键存在,函数 hasOwnProperty 返回false

这是我的代码:

$http({
        headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;' },
        url: '/Modules/Partners/Mailing/SendMail.ashx',
        data: $.param({ contact: JSON.stringify(contact), body: partnerObject.mailTemplate.longValue, title: "" }),
        method: 'POST'
    })
    .success(function (data, status, headers, config) {
        console.log(data);
        console.log(data.hasOwnProperty('error'));

       if (data.hasOwnProperty('error')) {
           deferred.reject(contact);
       } else {
           deferred.resolve(contact);
       }
       //console.log(data)

    })
    .error(function (data, status, headers, config) {
        deferred.reject(contact);
    });
Run Code Online (Sandbox Code Playgroud)

在控制台中,我可以看到该对象包含返回的“error”hasOwnProperty('error')false

在此输入图像描述

javascript json http angularjs

1
推荐指数
1
解决办法
1万
查看次数

开放 API 3 - 如何读取 Spring Boot 分页属性?

我正在使用 Spring Boot + Spring Rest Pagination + Open API 3。

@Operation(summary = "Find Contacts by name", description = "Name search by %name% format", tags = { "contact" })
@ApiResponses(value = {
        @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Contact.class)))) })

@Parameter(in = ParameterIn.QUERY, description = "Zero-based page index (0..N)", name = "page"
, content = @Content(schema = @Schema(type = "integer", defaultValue = "0")))
@Parameter(in = ParameterIn.QUERY, description = "The size of …
Run Code Online (Sandbox Code Playgroud)

spring spring-boot openapi springdoc

1
推荐指数
1
解决办法
9481
查看次数