我真的不知道如何在 Spring 中进行此操作。
我有一个 URL https://test.payu.in/merchant/postservice.php?form=2
,我必须使用一些参数调用它并使用结果。
我怎样才能用 Spring 做到这一点?
最佳答案
您可以使用 RestTemplate , 它支持 mashalling、unmarshalling、可变分辨率等。
例如,你必须做类似这样的事情:
Map<String, String> vars = new HashMap<String, String>();
vars.put("hotel", "42");
vars.put("booking", "21");
String result =
restTemplate.getForObject("http://example.com/hotels/{hotel}/bookings/{booking}", String.class, vars);
更多信息:
关于java - 如何从 spring 3.x 调用 web 服务或 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18916681/