小编Ali*_*jad的帖子

在Double Nested Array MongoDB中查找

我在mongodb有这个收藏

{
"_id" : "777",
"someKey" : "someValue",
"someArray" : [
    {
        "name" : "name1",
        "someNestedArray" : [
            {
                "name" : "value"
            },
            {
                "name" : "delete me"
            }
        ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我想找到基于someArray.someNestedArray.name的文档,但我找不到任何有用的链接所有关于更新嵌套数组的搜索结果我正在尝试这个但是什么都不返回

db.mycollection.find({"someArray.$.someNestedArray":{"$elemMatch":{"name":"1"}}})
db.mycollection.find({"someArray.$.someNestedArray.$.name":"1"})
Run Code Online (Sandbox Code Playgroud)

还有别的东西

我如何通过双嵌套数组mongodb中的元素找到?

mongodb mongodb-query aggregation-framework

17
推荐指数
2
解决办法
3万
查看次数

删除两个字符之间的任

我想删除"?"之间的任何内容 和"/"

我的文字是 "hi?0/hello/hi"

我需要看到这个

"hi?/hello/hi"
Run Code Online (Sandbox Code Playgroud)

我的代码是

key.replaceAll("\\?.*/","?/");
Run Code Online (Sandbox Code Playgroud)

但我的输出是

"hi?/hi"
Run Code Online (Sandbox Code Playgroud)

怎么了?

java

6
推荐指数
2
解决办法
103
查看次数

使用码头HTTP客户端发送Https请求中的NullPointerException

我正在使用Jetty HTTP客户端(v9.2.5)发送HTTP请求,对于HTTP请求{Post,Get,...}来说,它工作正常,但是当我发送HTTPS请求时,我看到了

java.util.concurrent.ExecutionException: java.lang.NullPointerException
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:642)
Run Code Online (Sandbox Code Playgroud)

我的功能是

private Object sendHttpPOSTRequest(String url, List<Header> headers,
        String content, HttpMethod method) {
    try {
        HttpClient client = new HttpClient();
        client.setMaxConnectionsPerDestination(16);
        client.setAddressResolutionTimeout(5000);
        client.setConnectTimeout(5000);
        client.setMaxRedirects(3);
        client.setFollowRedirects(true);
        client.setExecutor(_executor);
        client.start();
        Request req = client.POST(url).content(
                new StringContentProvider(content));
        if (headers != null)
            req = setHeaders(req, headers);
        req.header(HttpHeader.CONTENT_TYPE, "application/json");

        return req.send();

    } catch (Exception e) {
        e.printStackTrace();
        return "Failed";
    }

}
Run Code Online (Sandbox Code Playgroud)

怎么了?

java https httpclient jetty-9

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

按"?/"拆分不起作用

我想通过以下方式拆分字符串:"?/".我的字符串是:hello?/hi/hello.

我的代码是:

String [] list=myString.split("/?/");
Run Code Online (Sandbox Code Playgroud)

我的输出是:[HELLO,hi,hellow]但我希望看到:[hello,hi/hello].

我怎样才能做到这一点?

java regex split

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