如何根据多个参数过滤Web服务结果?

时间:2013-06-17 09:44:00

标签: java web-services spring rest sharepoint-2010

要过滤多个参数,请使用此Web服务调用:

http://mysite/sites/test/_vti_bin/listdata.svc/Values?$filter=param1%20eq%20'test1'%20and%20param2%20eq%20'test2'

但是如何以编程方式使用此过滤器?

要调用Web服务并传入我使用的过滤器名称和值:

Map<String, String> variables = new HashMap<String, String>();
variables.put("filterName", "param1");
variables.put("filterValue", "test1");

然后调用:

readOnlyRestTemplate.getForObject(url, String, variables);

这适用于过滤一个参数。但是如何根据多个参数进行过滤,在这个例子中包含名称/值对'param2 / test2'?

1 个答案:

答案 0 :(得分:0)

它应该与:

一起使用
Map<String, String> variables = new HashMap<String, String>();
variables.put("param1", "test1");
variables.put("param2", "test2");