小编Rah*_*Raj的帖子

如何使用百里香检查列表是否为空?

<div th:if="${tblUserList != null}">
 --content--
</div>
Run Code Online (Sandbox Code Playgroud)

上面的百万美元代码不起作用,其中tblUserList是一个列表.所以我想检查列表是否为空而不是检查它的null.怎么做?

html html5 thymeleaf

47
推荐指数
3
解决办法
6万
查看次数

CondaHTTPError:HTTP 000 CONNECTION FAILED for url <https://repo.continuum.io/pk gs/r/win-64/repodata.json.bz2>

我需要安装tensorflow并试图首先添加环境.但我收到HTTP连接失败错误.我是公司代理的后面,已经在.condarc文件中很好地定义了它们.这是我得到的错误:

C:\Users\Rahul\Downloads>conda create -n tensorflow python=3.6 anaconda
Solving environment: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url 
<https://repo.continuum.io/pk
gs/r/win-64/repodata.json.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your 
way.
ConnectionError(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io, por
t=443): Max retries exceeded with url: /pkgs/r/win-64/repodata.json.bz2 (Caused
by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0
000001A00393C88>: Failed to establish a new connection: [Errno 11002] getaddrinf
o failed',))",),)
Run Code Online (Sandbox Code Playgroud)

我在此问题跟踪器中详细介绍了此问题:https: //github.com/conda/conda/issues/7283

正如问题跟踪器中提到的,我已经尝试重置ssl,添加condarc文件等.但到目前为止还没有运气.我的代理正在按预期工作,我在condarc文件中的条目是正确的.连续存储库也可以通过浏览器访问而不会出现问题

没有任何命令喜欢conda …

python anaconda conda

11
推荐指数
5
解决办法
9773
查看次数

spring.http.multipart.enabled 与 spring.servlet.multipart.enabled 究竟有何不同?

在 Spring Boot 中,对于分段上传,我看到许多教程站点都建议具有以下属性之一:

spring.http.multipart.enabled=false

或者

spring.servlet.multipart.enabled=true

有人可以解释为什么这些设置及其用例吗?特别是如果我设置了属性spring.http.multipart.enabled=false,那为什么spring.servlet.multipart.enabled=true

我尝试通过 Stack Overflow 进行搜索,但没有找到与此相关的任何帖子。

java spring spring-mvc spring-boot

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

MongoDB按年份查找查询

如何执行find()与像一个状态下的操作{fromdt: 2016},其中fromdt是一个ISODate在后端。在检查stackoverflow帖子之后,我只能看到$year与聚合一起使用的一个选项。但基本上它使用投影,而我没有在文档中得到所有字段。所以我想知道如何在没有聚合的情况下实现这一目标?基本上,我想应用上述过滤器,并获取每个文档中包含所有字段的所有文档。

示例文件:

{
"_id" : 501.0,
"custid" : 1.0,
"fromdt" : ISODate("2016-01-23T00:00:00.000Z"),
"enddt" : ISODate("2017-01-22T00:00:00.000Z")
}
Run Code Online (Sandbox Code Playgroud)

有没有一种更好的方法,而不必2016-01-01T00:00:00.000Z仅通过将年份值过滤器设置为2016 来记住格式?

注意:请不要将其标记为重复,因为其他帖子中没有回答我的实际问题。

database mongodb mongodb-query

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

能够在不引用父类的情况下实例化静态内部类

在开始之前,我想指出这篇文章不是重复的:

如何在静态方法
实例化中实例化非静态内部类

为什么允许实例化静态嵌套类对象?

事实上,我想知道为什么它在我的示例代码中表现得很奇怪.根据我的理解,我们可以实例化一个静态内部类,如下所示:

new OuterClass.InnerClass();
Run Code Online (Sandbox Code Playgroud)

但在我的示例代码中,我能够实例化静态内部类,如:

new InnerClass();
Run Code Online (Sandbox Code Playgroud)

我将把我的示例代码放在这里:

import java.util.*;

class GFG {

static class ListComparator implements Comparator<Integer>{

            @Override
            public int compare(Integer o1, Integer o2){
                if(o1>o2){
                    return -1;
                }
                else if(o1<o2){
                    return 1;
                }
                else
                    return 0;
            }
}

public static void main (String[] args) {
    //code
    List<Integer> list = new ArrayList<Integer>();
    list.add(3);
    list.add(1);
    list.add(2);
    list.add(4);
    Collections.sort(list,new ListComparator());    
    for(Integer i : list){
        System.out.println(i);
    }

 }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码运行没有任何错误,我按降序输出.任何人都可以解释我如何能够直接实例化这样的静态内部类:new ListComparator();

我在这种情况下期待错误,但对输出感到惊讶.我知道我的静态内部类实现了Comparator接口,但我想知道使它静态会引起与静态类行为的冲突.但令人惊讶的是没有发生,我很好奇为什么它没有发生?

java collections static arraylist comparator

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

MongoDB-如何将浮点值总计截断为一或两个小数点?

假设这是查询:

db.movies.aggregate([
  {$match: {languages: "English", cast:{$exists:true}}},

  {$unwind: "$cast"},

  {$group: {_id: "$cast", numFilms:{$sum: 1}, average:{$avg: "$imdb.rating"}   
  }},

  {$sort: {numFilms:-1}},

  {$limit: 1}
])
Run Code Online (Sandbox Code Playgroud)

我得到的输出:

{ "_id" : "John Wayne", "numFilms" : 107, "average" : 6.424299065420561 }
Run Code Online (Sandbox Code Playgroud)

如何截断average到单/双小数点?我想看到这样的输出:

{ "_id" : "John Wayne", "numFilms" : 107, "average" : 6.42 }
Run Code Online (Sandbox Code Playgroud)

我尝试了这篇文章,但似乎我无法摆脱与$avg运算符做同样的事情。谁能告诉我如何实现这一目标?

并且请不要将前面提到的帖子直接标记为重复的帖子,这在这里没有回答我与$avg操作员有关的问题。

mongodb mongodb-query aggregation-framework

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

MongoDB-$ setIntersection与$ facet

这是我的查询:

db.movies.aggregate([
   {$facet:{
        rating:[{$match: {"imdb.rating":{$gte: 0},"metacritic":{$gte: 0}}}, 
   {$sort: {"imdb.rating":-1}},{$project: 
   {"title":1,"imdb.rating":1,"metacritic":1}},{$limit: 10}],

     critic:[{$match: {"metacritic":{$gte: 0},"imdb.rating":{$gte: 0}}}, 
   {$sort: {"metacritic": -1}},{$project: 
   {"title":1,"imdb.rating":1,"metacritic":1}},{$limit: 10}],

     intersection:[{$project: {common: {$setIntersection: 
   ["$rating","$critic"]}}}]

 }}


])
Run Code Online (Sandbox Code Playgroud)

我的样本数据集是:

{
"_id" : ObjectId("573a13cef29313caabd8709c"),
"title" : "Justin Bieber: Never Say Never",
"year" : 2011,
"runtime" : 105,
"released" : ISODate("2011-02-11T00:00:00.000Z"),
"cast" : [ 
    "Justin Bieber", 
    "Boys II Men", 
    "Miley Cyrus", 
    "Sean Kingston"
],
"metacritic" : 52,
"poster" : "http://ia.media-imdb.com/images/M/MV5BMTY0NDQzMjIzOF5BMl5BanBnXkFtZTcwNDk2NzczNA@@._V1_SX300.jpg",
"plot" : "Follows Justin Bieber with some footage of performances from his 2010 concert …
Run Code Online (Sandbox Code Playgroud)

mongodb mongodb-query aggregation-framework

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

AWS Cognito 在尝试登录时出现 BadRequest 错误

我试图实现 AWS cognito spring boot 示例,如此处所述

我在单击“使用 Amazon Cognito 登录”时收到以下错误:

{"code":"BadRequest","message":"The server did not understand the operation that was requested.","type":"client"}
Run Code Online (Sandbox Code Playgroud)

URI 是:

https://cognito-idp.{region}.amazonaws.com/{my-pool-id}/authorize?response_type=code&client_id={my-client-id}&scope=openid&state=NHfXN1aWjqUWiRBp0FZzIoZYHx-EmcuUp8sGDKUaODs%3D&redirect_uri=http://localhost:8080/login/oauth2/code/cognito&nonce=CgC_P_GCnLlHQ4W_9nT04hzwkjaDdPGs7OaLaklP0wU
Run Code Online (Sandbox Code Playgroud)

以下配置是我自己在排查问题时验证的。

  1. 客户端 ID、客户端密码、池 ID、区域等与我的 AWS 控制台中的配置完全相同。这里没有错误。

  2. 我正在使用 Cognito 提供的 UI 进行登录。域已添加并验证 Cognito UI 正在重定向到登录屏幕。

  3. 应用程序客户端设置中的回调 URI 与我的配置中的重定向 ui 相同。

我的示例配置文件链接到此处以供参考。

你能告诉我这里出了什么问题吗?我在这里错过了什么吗?

spring spring-security amazon-web-services spring-boot amazon-cognito

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

How to arrange scala parallel collections in insertion order?

Consider the below example:

object Test {
def main(args: Array[String]): Unit = {
  val vec = Vector(1,2,3,4,5,6)
  val x = vec.map(myFunc(_))
  x.foreach{println}

  val par = vec.par
  val parx = par.map(myFunc(_))
  parx.foreach{println}
}

def myFunc(a:Int) : Int  = {
 return a*a
 }
}
Run Code Online (Sandbox Code Playgroud)

when I print x, it follows insertion order, while parx follows random order. How to preserve the insertion order here? I'm using Vector in this example, but it happens in other collections such as List too.

scala vector scala-collections

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