错误信息
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>
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>
解决方案 »
- ext内存分页问题?很急,请高手帮忙....
- 如何重用Tomcat里编译的类文件
- 那位高手能简而且精地讲一下WEBWORK的基础知识...
- Hibernate插入信息错误,求解
- <a href="javascript:history.back(1)?<%=request.getPatameter()%>,这样写为什么不对????
- C#加密,JAVA解密的问题
- 问大家个问题 后台插进数据 在前台显示无空格和换行了怎么办?在线等
- 变量和property的比较怎么进行?????
- javaz中如何连接mysql数据库?
- 显示问题
- 请问web工程能打成jar包吗?
- 会AS3的高手请进(尤其是做过战旗游戏的)
你这里是不是写错了??
改成
mySmartUpload.setAllowedFilesList("htm,html,txt");
试试。
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); }