用于HighChart导出服务器REST服务的Java客户端

时间:2014-12-09 14:06:15

标签: java json spring rest highcharts

我一直在尝试创建一个小型的Java客户端来调用Highchart Export服务器以获取pdf / jpeg等。但是使用Spring的RestTemplate - >它并不成功。 RestTemplate restTemplate =客户端的新org.springframework.web.client.RestTemplate()。我尝试了post / get / exchange方法..但无法将所需的方法参数传递给服务器端...所需的方法是在没有params的情况下调用并返回其测试jsp页面。

Highchart导出服务器代码=>

@Controller
@RequestMapping("/")
public class ExportController extends HttpServlet {
...
...
    @RequestMapping(method = {RequestMethod.POST, RequestMethod.GET})
    public HttpEntity<byte[]> exporter(
        @RequestParam(value = "svg", required = false) String svg,
        @RequestParam(value = "type", required = false) String type,
        @RequestParam(value = "filename", required = false) String filename,
        @RequestParam(value = "width", required = false) String width,
        @RequestParam(value = "scale", required = false) String scale,
        @RequestParam(value = "options", required = false) String options,
        @RequestParam(value = "globaloptions", required = false) String globalOptions,
        @RequestParam(value = "constr", required = false) String constructor,
        @RequestParam(value = "callback", required = false) String callback,
        @RequestParam(value = "callbackHC", required = false) String callbackHC,
        @RequestParam(value = "async", required = false, defaultValue = "false")  Boolean async,
        @RequestParam(value = "jsonp", required = false, defaultValue = "false") Boolean jsonp,
        HttpServletRequest request,
        HttpSession session) throws ServletException, InterruptedException, SVGConverterException, NoSuchElementException, PoolException, TimeoutException, IOException, ZeroRequestParameterException {
...
}

}

我应该调用RestTemplate中的哪个方法以及如何从客户端传递params,如JSON格式的选项,类型等,以便上面的Service方法使用适当的参数执行?感谢您的帮助。

0 个答案:

没有答案