要答辩咯急啊 在线等 用jspsmart编写的东西 怎么老出错啊
是从例子该过来的 就是把上传文件的信息存入数据库但不存文件
<%@ page language= "java " import= "com.jspsmart.upload.* "%>
<%@include file= "conn.jsp "%> //提供了数据库的连接statement等的初始化
<jsp:useBean id= "mySmartUpload " scope= "page " class= "com.jspsmart.upload.SmartUpload " />
<HTML>
<BODY>
<H1> jspSmartUpload : Sample 2 </H1>
<HR>
<%
String zh=(String)session.getAttribute( "ZGBH ");
int ZGBH=Integer.parseInt(zh);
// Variables
int count=0; //这里eclipse老报错Duplicate local variable count说是重载了变量
// Initialization
mySmartUpload.initialize(pageContext);
// Upload
mySmartUpload.upload();
// Select each file
for (int i=0;i <mySmartUpload.getFiles().getCount();i++){
// Retreive the current file
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
if (!myFile.isMissing()) {
// Save the files with its original names in a virtual path of the web server
myFile.saveAs( "/upload/ " + myFile.getFileName());
String filename=myFile.getFileName();
String fileext=myFile.getFileExt();
int filesize=myFile.getSize();
String sql= "insert into ZZ_GRWJB values( ' "+ZGBH+ " ', ' "+filename+ " ', ' "+fileext+ " ', ' "+filesize+ " ') ";
stmt.executeUpdate(sql);
count ++;
}
}
%>
<script language= "javascript ">
alert( "ok ");
window.navigate( "wjliebiao.jsp ");
</script>
</BODY>
</HTML>
运行时的报错为
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 15 in the jsp file: /doupload.jsp
Duplicate local variable count
12: int ZGBH=Integer.parseInt(zh);
13:
14: // Variables
15: int count=0;
16:
17: // Initialization
18: mySmartUpload.initialize(pageContext);
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java