日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

java使用smartupload組件實(shí)現(xiàn)文件上傳的方法(2)_JSP教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:jsp利用application統(tǒng)計(jì)在線人數(shù)的方法
這篇文章主要介紹了jsp利用application統(tǒng)計(jì)在線人數(shù)的方法,代碼中備有較為詳盡的注釋便于理解,是比較實(shí)用的技巧,需要的朋友可以參考下 本文實(shí)例講述了jsp利用application統(tǒng)計(jì)在線人數(shù)的方法。分享給大家供大家參考。 具體實(shí)現(xiàn)方法如下: 代碼如下:%@ page language=jav

smartupload是由www.jspsmart.com網(wǎng)站開發(fā)的一套上傳組件包,可以輕松的實(shí)現(xiàn)文件的上傳及下載功能,smartupload組件使用簡(jiǎn)單、可以輕松的實(shí)現(xiàn)上傳文件類型的限制、也可以輕易的取得上傳文件的名稱、后綴、大小等。

smartupload本身是一個(gè)系統(tǒng)提供的jar包(smartupload.jar),用戶直接將此包放到classpath下即可,也可以直接將此包拷貝到TOMCAT_HOME\lib目錄之中。

下面使用組件完成上傳

單一文件上傳:

代碼如下: <html>
<head><title>smartupload組件上傳</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<form action="smartupload_demo01.jsp" method="post" enctype="multipart/form-data">
圖片<input type="file" name="pic">
<input type="submit" value="上傳">
</form>
</body>
</html>

 

jsp代碼:

smartupload_demo01.jsp

代碼如下: <%@ page contentType="text/html" pageEncoding="utf-8"%>
<%@ page import="com.jspsmart.upload.*" %>
<html>
<head><title>smartupload組件上傳01</title></head>

 

<body>
<%
SmartUpload smart = new SmartUpload() ;
smart.initialize(pageContext) ; // 初始化上傳操作
smart.upload(); // 上傳準(zhǔn)備
smart.save("upload") ; // 文件保存
out.print("上傳成功");
%>

</body>
</html>

 

批量上傳:

html文件

 

代碼如下: <html>
<head><title>smartupload組件上傳02</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<form action="smartupload_demo02.jsp" method="post" enctype="multipart/form-data">
圖片<input type="file" name="pic1"><br>
圖片<input type="file" name="pic2"><br>
圖片<input type="file" name="pic3"><br>
<input type="submit" value="上傳">
<input type="reset" value="重置">
</form>
</body>
</html>

 

jsp代碼

smartupload_demo02.jsp

代碼如下: <%@ page contentType="text/html" pageEncoding="utf-8"%>
<%@ page import="com.jspsmart.upload.*"%>
<%@ page import="com.zhou.study.*"%>
<html>
<head><title>smartupload組件上傳02</title></head>
<body>
<%
SmartUpload smart = new SmartUpload() ;
smart.initialize(pageContext) ; // 初始化上傳操作
smart.upload() ; // 上傳準(zhǔn)備
String name = smart.getRequest().getParameter("uname") ;
IPTimeStamp its = new IPTimeStamp("192.168.1.1") ; // 取得客戶端的IP地址
for(int x=0;x<smart.getFiles().getCount();x++){
String ext = smart.getFiles().getFile(x).getFileExt() ; // 擴(kuò)展名稱
String fileName = its.getIPTimeRand() + "." + ext ;
smart.getFiles().getFile(x).saveAs(this.getServletContext().getRealPath("/")+"upload"+java.io.File.separator + fileName) ;
}
out.print("上傳成功");
%>
</body>
</html>

 

注意:在TOMCAT_HOME/項(xiàng)目目錄下建立upload文件夾才能正常運(yùn)行!

簡(jiǎn)單上傳操作上傳后的文件名稱是原本的文件名稱�?赏ㄟ^工具類重命名。

分享:jsp分頁(yè)顯示完整實(shí)例
這篇文章主要介紹了jsp分頁(yè)顯示完整實(shí)例,以文章管理頁(yè)面為例詳細(xì)分析了jsp的分頁(yè)顯示實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下 本文實(shí)例講述了jsp分頁(yè)顯示的實(shí)現(xiàn)方法。分享給大家供大家參考。 具體實(shí)現(xiàn)方法如下: 代碼如下:%@ page contentType=text/html;

來源:模板無(wú)憂//所屬分類:JSP教程/更新時(shí)間:2015-01-31
相關(guān)JSP教程