我有一个JSP文件,它在try块中包含以下代码:
String AccountName = request.getParameter("accountName");
String[] b=AccountName.split("/");
String c=b[0];
String s="select * from account_version where acc_id in (Select acc_id from account where acc_name="+"'"+c+"'"+")";
ResultSet rs = statement.executeQuery(s);
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Account_Version");
HSSFRow rowhead = sheet.createRow((short) 0);
rowhead.createCell((short) 0).setCellValue("Line ID");
rowhead.createCell((short) 1).setCellValue("Account ID");
rowhead.createCell((short) 2).setCellValue("Version Number");
rowhead.createCell((short) 3).setCellValue("Chargable FTE");
rowhead.createCell((short) 4).setCellValue("Cost Call Date");
rowhead.createCell((short) 5).setCellValue("Is Approved");
int i = 1;
while (rs.next()){
HSSFRow row = sheet.createRow((short) i);
row.createCell((short) 0).setCellValue(rs.getInt("line_id"));
row.createCell((short) 1).setCellValue(rs.getInt("acc_id"));
row.createCell((short) 2).setCellValue(rs.getInt("version_no"));
row.createCell((short) 3).setCellValue(rs.getInt("chargable_fte"));
row.createCell((short) 4).setCellValue(rs.getDate("cost_call_date"));
row.createCell((short) 5).setCellValue(rs.getBoolean("is_approved"));
i++;
}
String yemi = "C:/Users/IBM_ADMIN/Desktop/test.xls";
FileOutputStream fileOut = new FileOutputStream(yemi);
workbook.write(fileOut);
fileOut.close();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
在这个文件中,每当我包含以下几行时,我都会遇到异常:
org.apache.jasper.JasperException: An exception occurred processing JSP page
如果没有这两行,文件运行正常:
String[] b=AccountName.split("/");
String c=b[0];
答案 0 :(得分:0)
在拆分字符串之前尝试打印AccountName值。我想斜线(/)在变量中不可用,这就是你得到这个错误的原因。
**
String AccountName = request.getParameter("accountName");
System.out.println(AccountName);
**