嗨伙计们!!!我生成了一个简单的参数化 jasper 报告,用于将数据导出为 pdf 格式。现在,根据我的代码,pdf 文件正在通过自动下载生成和打开,而我需要 Saveas 对话框来询问 openwith 或 saveas ...任何建议将不胜感激.. .Thanx提前..这是我的代码...
ServletOutputStream servletOutputStream = response.getOutputStream();
InputStream reportStream = getServletConfig().getServletContext().getResourceAsStream("para.jasper");
try {
String name = request.getParameter("name");
System.out.println(name);
String query = "Select * from vikas where vikas.name='" + name + "'";
System.out.println(query);
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/techsoft?user=root&password=techsoft");
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(resultSet);
JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, new HashMap(), resultSetDataSource);
resultSet.close();
statement.close();
connection.close();
servletOutputStream.flush();
servletOutputStream.close();