⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample2.jsp

📁 《精通JSP编程 》源代码(赵强那本) 很有用的源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ 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 2</H1>
<HR>

<%
	
	
	// 声明变量count,用来存储上传文件个数
	int count=0;        

	// 执行初始化操作
	mySmartUpload.initialize(pageContext);

	// 上传文件到服务器	
	mySmartUpload.upload();

	// 对上传到服务器的文件进行逐个处理
	for (int i=0;i<mySmartUpload.getFiles().getCount();i++){

		// 取出一个文件
		com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);

		// 只有myFile代表的文件存在时才执行存储操作
		if (!myFile.isMissing()) {

			// 保存该文件到web应用程序下的upload目录       
			myFile.saveAs("/upload/" + myFile.getFileName());
			

			//  显示当前文件信息
			out.println("FieldName = " + myFile.getFieldName() + "<BR>");
			out.println("Size = " + myFile.getSize() + "<BR>");
			out.println("FileName = " + myFile.getFileName() + "<BR>");
			out.println("FileExt = " + myFile.getFileExt() + "<BR>");
			out.println("FilePathName = " + myFile.getFilePathName() + "<BR>");
			out.println("ContentType = " + myFile.getContentType() + "<BR>");
			out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>");
			out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>");
			out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>");

			count ++;

		}

	}

	// Display the number of files which could be uploaded 
	out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>");

	// Display the number of files uploaded 
	out.println(count + " file(s) uploaded.");


%>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -