gpt4 book ai didi

java - 试图取回 JasperPrint 作为服务器的返回类型

转载 作者:行者123 更新时间:2023-12-03 11:49:07 30 4
gpt4 key购买 nike

我有一个服务器端代码作为

    @POST
@Path("/getJasperPrint")
public JasperPrint getReport(ReportMapper reportMapper,@Context HttpServletRequest request,@Context HttpServletResponse response) throws Exception{
jasperPrint = JasperFillManager.fillReport(jasperReport, reportMap,
DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb" + "?user=" + "admin" + "&password=" + "admin"));
return jasperPrint ;
}

我正在尝试使用 RestTemplate 作为

  RestTemplate abc = new RestTemplate();
JasperPrint jasperPrint = abc.postForObject("http://localhost:8008/report/getJasperPrint", objectA, JasperPrint.class);

报错

no suitable HttpMessageConverter found for response type [class path to jasperPrint].

我需要在这里做的任何事情。

最佳答案

Spring 源码博文

Objects passed to and returned from the methods getForObject(), postForLocation(), and put() and are converted to HTTP requests and from HTTP responses by HttpMessageConverters.

我认为您需要编写自己的转换器才能获得 jasperprint 的响应

关于java - 试图取回 JasperPrint 作为服务器的返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26840802/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com