【问题标题】:get node with where clause in jersey and neo4j在球衣和neo4j中获取带有where子句的节点
【发布时间】:2014-02-10 14:27:57
【问题描述】:

如果有人可以帮助我,那将是一种乐趣

我正在尝试在 neo4j 中使用 jersey 进行远程密码查询

public static URI getData(HashMap<String,String> params,String query){
    JSONObject jObject = new JSONObject();
    String SERVER_ROOT_URI = "http://localhost:7474/db/data/";
     String cypherUri = SERVER_ROOT_URI + "cypher/";
        try {
            jObject.put("query", query);
            jObject.put("params", params);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        WebResource resource = Client.create()
                .resource( cypherUri );
        ClientResponse response = resource.accept( MediaType.APPLICATION_JSON_TYPE )
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(jObject.toString())
                .post(ClientResponse.class);
        System.out.println( String.format( "POST to [%s], status code [%d], reponse [%s]",
                cypherUri, response.getStatus(),response.getLocation()) );

        response.close();
        return response.getLocation();
}

在响应中,状态代码为 200,所以可以,但 response.getLocation() 为空 我确实验证了传入参数的 json 它是一个有效的 json 我手动在密码中执行了查询,它给出了一些行。

【问题讨论】:

  • 你能举一个你的密码查询的例子,以及你想要什么作为响应(正文和标题)吗?我真的不明白你想要什么。干杯。
  • 这是我使用密码查询创建参数的地方: public static boolean isLoginCorrect(String pseudo,String password) throws NoSuchAlgorithmException{ HashMap params = new HashMap(); params.put("伪", 伪); params.put("密码", Security.getInstance().getMd5Key(password));字符串查询 = " MATCH (n) WHERE n.pseudo = '"+pseudo+"' RETURN n"; if(RESTUtil.getData(params, query) != null ) 返回 true;返回假; } 谢谢

标签: java json neo4j jersey cypher


【解决方案1】:

当您进行密码查询时,标头中没有任何内容,所有响应都在正文中作为 JSON。

【讨论】:

    【解决方案2】:

    我终于找到了答案。我的 JSON 响应:

    response.getEntity(String.class)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多