【发布时间】: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