初学ireport,遇到问题,求指导:An error occurred at line: 20 in the jsp file: /reportRun.jsp Jaspe 80
<%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><%@p...
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="net.sf.jasperreports.engine.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%
String ctxpath = request.getContextPath();
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/ireport";
String user = "root";
String password = "123";
Connection conn = DriverManager.getConnection(url, user, password);
File reportFile = new File(this.getServletContext().getRealPath(
"/report2.jasper"));
Map parameters = new HashMap();
try {
JasperRunManager.runReportToHtmlFile(reportFile.getPath(),parameters, conn);
response.sendRedirect(ctxpath + "/myreport.html");
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
conn.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
} }
%>
运行后出现错误:An error occurred at line: 20 in the jsp file: /reportRun.jsp
JasperRunManager cannot be resolved
17: Map parameters = new HashMap();
18: try {
19:
20: JasperRunManager.runReportToHtmlFile(reportFile.getPath(),parameters, conn);
21: response.sendRedirect(ctxpath + "/myreport.html");
22: } catch (Exception e) {
23: System.out.println(e.getMessage()); 展开
pageEncoding="UTF-8"%>
<%@ page import="net.sf.jasperreports.engine.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%
String ctxpath = request.getContextPath();
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/ireport";
String user = "root";
String password = "123";
Connection conn = DriverManager.getConnection(url, user, password);
File reportFile = new File(this.getServletContext().getRealPath(
"/report2.jasper"));
Map parameters = new HashMap();
try {
JasperRunManager.runReportToHtmlFile(reportFile.getPath(),parameters, conn);
response.sendRedirect(ctxpath + "/myreport.html");
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
conn.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
} }
%>
运行后出现错误:An error occurred at line: 20 in the jsp file: /reportRun.jsp
JasperRunManager cannot be resolved
17: Map parameters = new HashMap();
18: try {
19:
20: JasperRunManager.runReportToHtmlFile(reportFile.getPath(),parameters, conn);
21: response.sendRedirect(ctxpath + "/myreport.html");
22: } catch (Exception e) {
23: System.out.println(e.getMessage()); 展开
2个回答
展开全部
看看reportFile对象是不是为空,直接这样获取不太对,试试绝对地址。application.getRealPath ("/report2.jaspe")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询