错误信息
org.apache.jasper.JasperException: Exception in JSP: /jsp/sample3.jsp:3431:  // mySmartUpload.setTotalMaxFileSize(200000);
32: 
33:  // Upload
34:     mySmartUpload.upload();
35: 
36:  // Save the files with their original names in a virtual path of the web server
37:     try {sample3.jsp代码
<%@ page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><HTML>
<BODY BGCOLOR="white"><H1>jspSmartUpload : Sample 3</H1>
<HR><%

// Variables
   int count=0;         // Initialization
mySmartUpload.initialize(pageContext); // Only allow txt or htm files
   mySmartUpload.setAllowedFilesList("htm,html,txt,,"); // DeniedFilesList can also be used :
    // mySmartUpload.setDeniedFilesList("exe,bat,jsp"); // Deny physical path
// mySmartUpload.setDenyPhysicalPath(true); // Only allow files smaller than 50000 bytes
// mySmartUpload.setMaxFileSize(50000); // Deny upload if the total fila size is greater than 200000 bytes
// mySmartUpload.setTotalMaxFileSize(200000); // Upload
   mySmartUpload.upload(); // Save the files with their original names in a virtual path of the web server
   try {  count = mySmartUpload.save("/upload", mySmartUpload.SAVE_VIRTUAL);
  
   } catch (Exception e){    out.println("<b>Wrong selection : </b>" + e.toString());    }
   
// Display the number of files uploaded
   out.println(count + " file(s) uploaded.");%>
</BODY>
</HTML>

解决方案 »

  1.   

    上面报错的好像是因为mySmartUpload.upload();不能用,但是到网上都找不到有结果
      

  2.   

    mySmartUpload.setAllowedFilesList("htm,html,txt,,");
     
    你这里是不是写错了??
    改成
    mySmartUpload.setAllowedFilesList("htm,html,txt");
    试试。
      

  3.   

    // 新建一个SmartUpload对象
    SmartUpload su = new SmartUpload();
    // 上传初始化
    su.initialize(pageContext);
    // 设定上传限制
    // 1.限制每个上传文件的最大长度。
    // su.setMaxFileSize(10000);
    // 2.限制总上传数据的长度。
    // su.setTotalMaxFileSize(20000);
    // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。
    // su.setAllowedFilesList("doc,txt");
    // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,
    //jsp,htm,html扩展名的文件和没有扩展名的文件。
    // su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
    // 上传文件
    su.upload();
    // 将上传文件全部保存到指定目录
    int count = su.save("指定目录");
    out.println(count+"个文件上传成功!<br>");

    // 逐一提取上传文件信息,同时可保存文件。
    for (int i=0;i<su.getFiles().getCount();i++)
    {
    com.jspsmart.upload.File file = su.getFiles().getFile(i);

    // 若文件不存在则继续
    if (file.isMissing()) continue; // 显示当前文件信息
    out.println("<TABLE BORDER=1>");
    out.println("<TR><TD>表单项名(FieldName)</TD><TD>"
    + file.getFieldName() + "</TD></TR>");
    out.println("<TR><TD>文件长度(Size)</TD><TD>" + 
    file.getSize() + "</TD></TR>");
    out.println("<TR><TD>文件名(FileName)</TD><TD>" 
    + file.getFileName() + "</TD></TR>");
    out.println("<TR><TD>文件扩展名(FileExt)</TD><TD>" 
    + file.getFileExt() + "</TD></TR>");
    out.println("<TR><TD>文件全名(FilePathName)</TD><TD>"
    + file.getFilePathName() + "</TD></TR>");
    out.println("</TABLE><BR>"); // 将文件另存
    // file.saveAs("/upload/" + myFile.getFileName());
    // 另存到以WEB应用程序的根目录为文件根目录的目录下
    // file.saveAs("/upload/" + myFile.getFileName(), 
    //su.SAVE_VIRTUAL);
    // 另存到操作系统的根目录为文件根目录的目录下
    // file.saveAs("c:\\temp\\" + myFile.getFileName(), 
    //su.SAVE_PHYSICAL); }
      

  4.   

    jsp:useBean id="mySmartUpload"这个存在么?
      

  5.   

    存在阿在com.jspsmart.upload.SmartUpload中里面有一个是定义mySmartUpload