请帮我解决,我真的不知道!请
/ * - 要更改此模板,请选择“工具”|模板 - 并在编辑器中打开模板。 * / - package pdfprint;
import com.jaspersoft.ireport.jasperserver.JServer; import
com.jaspersoft.ireport.jasperserver.ws.WSClient; import
java.util.HashMap; import java.util.*; import
net.sf.jasperreports.engine.JasperPrint; import
net.sf.jasperreports.engine.JasperReport; import
net.sf.jasperreports.engine.export.JRPrintServiceExporter; import
net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.view.JasperViewer;
public class Pdfprint {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try{
JServer server = new JServer();
server.setUrl("http://localhost:8080/jasperserver/services/repository");
server.setUsername("jasperadmin");
server.setPassword("jasperadmin");
ResourceDescriptor rd = new ResourceDescriptor();
rd.setUriString("/solucisv3_testing/jr_testing_print");
WSClient client = new WSClient(server);
List list = client.list(rd);
Map params = new HashMap();
params.put("Plb_Company", "Company");
params.put("Plb_Address", "Address");
params.put("Plb_Title","Title");
params.put("PCondition","SELECT * FROM v_doc_ticketing WHERE f_doc_no='MYCSB0000096'");
JasperPrint printer = client.runReport(rd, params);
JasperViewer.viewReport(printer, false,Locale.GERMAN);
JRPrintServiceExporter exporter;
exporter = new JRPrintServiceExporter();
//exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
Boolean.TRUE);
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,"this.print({bUI:
false,bSilent: true,bShrinkToFit: true});");
exporter.exportReport(); } catch(Exception ex){ }
} }
我在这行列表中有一些错误列表= client.list(rd);
错误代码=没有为列表找到合适的方法(pdfprint.ResourceDescriptor) 方法WSClient.list(String)不适用 (实际参数pdfprint.ResourceDescriptor不能通过方法调用转换转换为String) 方法WSClient.list(com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor)不适用 (实际参数pdfprint.ResourceDescriptor无法通过方法调用转换转换为com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor)
和JasperPrint printer = client.runReport(rd,params,list);
也有同样的错误
错误代码=找不到适合runReport的方法(pdfprint.ResourceDescriptor,Map,List) 方法WSClient.runReport(com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor,Map,List)不适用 (实际参数pdfprint.ResourceDescriptor无法通过方法调用转换转换为com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor) 方法WSClient.runReport(com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor,Map)不适用 (实际和正式的参数列表长度不同)
答案 0 :(得分:1)
您正在传递pdfprint.ResourceDescriptor
而不是com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor
。
您可能在IDE中意外地在当前包中创建了ResourceDescriptor
类,而不是导入现有的类。如果是这样,只需从包中删除该类,并为正确的类添加一个import语句,确保它位于项目的类路径中。