我试过双反斜杠的东西,但它一直给我同样的错误。下面提供的是我正在使用的代码:
<%@ page import="java.io.*"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page import="net.sf.jasperreports.engine.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Planning</title>
</head>
<body>
<h2>Planning</h2>
<%
Connection conn = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:sqlserver://DC1VCWSQL105\sql05:1433;databaseName=TD_DA_Test;integratedSecurity=True");
} catch (Exception ex) {
ex.printStackTrace();
}
File reportFile = new File(application.getRealPath("//bespoke//rapport//Planning.jasper"));
Map parameters = new HashMap();
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream outStream = response.getOutputStream();
outStream.write(bytes, 0, bytes.length);
outStream.flush();
outStream.close();
%>
</body>
为什么 \ 在我的情况下不起作用?确切的错误是:
发生了错误:
PWC6033: Unable to compile class for JSP PWC6197: An error occurred at line: 18 in the jsp file: /bespoke/rapportplanning/Planning.jsp PWC6199: Generated servlet error: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP PWC6197