??xml version="1.0" encoding="utf-8" standalone="yes"?>日本一二三区在线视频,亚洲精品美女久久久,亚洲天堂男人天堂http://www.aygfsteel.com/f6k66ve/category/44049.html遇高山,我M风而翔Q逢江治I我凌波微?/description>zh-cnWed, 23 May 2012 21:59:56 GMTWed, 23 May 2012 21:59:56 GMT60java中断点箋?/title><link>http://www.aygfsteel.com/f6k66ve/archive/2012/05/23/378940.html</link><dc:creator>askzs</dc:creator><author>askzs</author><pubDate>Wed, 23 May 2012 07:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/f6k66ve/archive/2012/05/23/378940.html</guid><wfw:comment>http://www.aygfsteel.com/f6k66ve/comments/378940.html</wfw:comment><comments>http://www.aygfsteel.com/f6k66ve/archive/2012/05/23/378940.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/f6k66ve/comments/commentRss/378940.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/f6k66ve/services/trackbacks/378940.html</trackback:ping><description><![CDATA[<p>转蝲?<a >http://www.ibm.com/developerworks/cn/java/joy-down/</a><a name="1"><span id="wmqeeuq" class="atitle"><br /><br />断点l传的原?/span></a></p> <p>其实断点l传的原理很单,是?Http 的请求上和一般的下蝲有所不同而已?<br />打个比方Q浏览器h服务器上的一个文Ӟ所发出的请求如下:(x) <br />假设服务器域名ؓ(f) wwww.sjtu.edu.cnQ文件名?down.zip?<br />GET /down.zip HTTP/1.1 <br />Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms- <br />excel, application/msword, application/vnd.ms-powerpoint, */* <br />Accept-Language: zh-cn <br />Accept-Encoding: gzip, deflate <br />User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) <br />Connection: Keep-Alive </p> <p>服务器收到请求后Q按要求Lh的文Ӟ提取文g的信息,然后q回l浏览器Q返回信息如下:(x)</p> <p>200 <br />Content-Length=106786028 <br />Accept-Ranges=bytes <br />Date=Mon, 30 Apr 2001 12:56:11 GMT <br />ETag=W/"02ca57e173c11:95b" <br />Content-Type=application/octet-stream <br />Server=Microsoft-IIS/5.0 <br />Last-Modified=Mon, 30 Apr 2001 12:56:11 GMT </p> <p>所谓断点箋传,也就是要从文件已l下载的地方开始l下载。所以在客户端浏览器传给 Web 服务器的时候要多加一条信?-- 从哪里开始?<br />下面是用自己~的一?览?来传递请求信息给 Web 服务器,要求?2000070 字节开始?<br />GET /down.zip HTTP/1.0 <br />User-Agent: NetFox <br />RANGE: bytes=2000070- <br />Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 </p> <p>仔细看一下就?x)发现多了(jin)一?RANGE: bytes=2000070- <br />q一行的意思就是告诉服务器 down.zip q个文g?2000070 字节开始传Q前面的字节不用传了(jin)?<br />服务器收到这个请求以后,q回的信息如下:(x) <br />206 <br />Content-Length=106786028 <br />Content-Range=bytes 2000070-106786027/106786028 <br />Date=Mon, 30 Apr 2001 12:55:20 GMT <br />ETag=W/"02ca57e173c11:95b" <br />Content-Type=application/octet-stream <br />Server=Microsoft-IIS/5.0 <br />Last-Modified=Mon, 30 Apr 2001 12:55:20 GMT </p> <p>和前面服务器q回的信息比较一下,׃(x)发现增加?jin)一行:(x) <br />Content-Range=bytes 2000070-106786027/106786028 <br />q回的代码也改ؓ(f) 206 ?jin),而不再是 200 ?jin)?</p> <p>知道?jin)以上原理,可以进行断点箋传的~程?jin)?</p> <div id="wmqeeuq" class="ibm-alternate-rule"> <hr /> </div> <p class="ibm-ind-link ibm-back-to-top"><a class="ibm-anchor-up-link" >回页?/a></p> <p><a name="2"><span id="wmqeeuq" class="atitle">Java 实现断点l传的关键几?/span></a></p> <ol><li>(1) 用什么方法实现提?RANGE: bytes=2000070-?<br />当然用最原始?Socket 是肯定能完成的,不过那样太费事了(jin)Q其?Java ?net 包中提供?jin)这U功能。代码如下:(x) <br /><br />URL url = new URL("http://www.sjtu.edu.cn/down.zip"); <br />HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection(); <br /><br />// 讄 User-Agent <br />httpConnection.setRequestProperty("User-Agent","NetFox"); <br />// 讄断点l传的开始位|?<br />httpConnection.setRequestProperty("RANGE","bytes=2000070"); <br />// 获得输入?<br />InputStream input = httpConnection.getInputStream(); <br /> <p>从输入流中取出的字节就?down.zip 文g?2000070 开始的字节。大家看Q其实断点箋传用 Java 实现hq是很简单的吧。接下来要做的事是怎么保存获得的流到文件中M(jin)?</p></li><li>保存文g采用的方法?<br />我采用的?IO 包中?RandAccessFile cR?<br />操作相当单,假设?2000070 处开始保存文Ӟ代码如下Q?<br />RandomAccess oSavedFile = new RandomAccessFile("down.zip","rw"); <br />long nPos = 2000070; <br />// 定位文g指针?nPos 位置 <br />oSavedFile.seek(nPos); <br />byte[] b = new byte[1024]; <br />int nRead; <br />// 从输入流中读入字节流Q然后写到文件中 <br />while((nRead=input.read(b,0,1024)) > 0) <br />{ <br />oSavedFile.write(b,0,nRead); <br />} <br /></li></ol> <p>怎么P也很单吧。接下来要做的就是整合成一个完整的E序?jin)。包括一pd的线E控制等{?</p> <div id="wmqeeuq" class="ibm-alternate-rule"> <hr /> </div> <p><a name="3"><span id="wmqeeuq" class="atitle">断点l传内核的实?/span></a></p> <p>主要用了(jin) 6 个类Q包括一个测试类?<br />SiteFileFetch.java 负责整个文g的抓取,控制内部U程 (FileSplitterFetch c?)?<br />FileSplitterFetch.java 负责部分文g的抓取?<br />FileAccess.java 负责文g的存储?<br />SiteInfoBean.java 要抓取的文g的信息,如文件保存的目录Q名字,抓取文g?URL {?<br />Utility.java 工具c,放一些简单的Ҏ(gu)?<br />TestMethod.java 试cR?<br /></p> <p>下面是源E序Q?/p> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tbody> <tr> <td class="code-outline"><pre class="displaycode">/* /* * SiteFileFetch.java */ package NetFox; import java.io.*; import java.net.*; public class SiteFileFetch extends Thread { SiteInfoBean siteInfoBean = null; // 文g信息 Bean long[] nStartPos; // 开始位|? long[] nEndPos; // l束位置 FileSplitterFetch[] fileSplitterFetch; // 子线E对? long nFileLength; // 文g长度 boolean bFirst = true; // 是否W一ơ取文g boolean bStop = false; // 停止标志 File tmpFile; // 文g下蝲的(f)时信? DataOutputStream output; // 输出到文件的输出? public SiteFileFetch(SiteInfoBean bean) throws IOException { siteInfoBean = bean; //tmpFile = File.createTempFile ("zhong","1111",new File(bean.getSFilePath())); tmpFile = new File(bean.getSFilePath()+File.separator + bean.getSFileName()+".info"); if(tmpFile.exists ()) { bFirst = false; read_nPos(); } else { nStartPos = new long[bean.getNSplitter()]; nEndPos = new long[bean.getNSplitter()]; } } public void run() { // 获得文g长度 // 分割文g // 实例 FileSplitterFetch // 启动 FileSplitterFetch U程 // {待子线E返? try{ if(bFirst) { nFileLength = getFileSize(); if(nFileLength == -1) { System.err.println("File Length is not known!"); } else if(nFileLength == -2) { System.err.println("File is not access!"); } else { for(int i=0;i<nStartPos.length;i++) { nStartPos[i] = (long)(i*(nFileLength/nStartPos.length)); } for(int i=0;i<nEndPos.length-1;i++) { nEndPos[i] = nStartPos[i+1]; } nEndPos[nEndPos.length-1] = nFileLength; } } // 启动子线E? fileSplitterFetch = new FileSplitterFetch[nStartPos.length]; for(int i=0;i<nStartPos.length;i++) { fileSplitterFetch[i] = new FileSplitterFetch(siteInfoBean.getSSiteURL(), siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(), nStartPos[i],nEndPos[i],i); Utility.log("Thread " + i + " , nStartPos = " + nStartPos[i] + ", nEndPos = " + nEndPos[i]); fileSplitterFetch[i].start(); } // fileSplitterFetch[nPos.length-1] = new FileSplitterFetch(siteInfoBean.getSSiteURL(), siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(),nPos[nPos.length-1],nFileLength,nPos.length-1); // Utility.log("Thread " +(nPos.length-1) + ",nStartPos = "+nPos[nPos.length-1]+", nEndPos = " + nFileLength); // fileSplitterFetch[nPos.length-1].start(); // {待子线E结? //int count = 0; // 是否l束 while 循环 boolean breakWhile = false; while(!bStop) { write_nPos(); Utility.sleep(500); breakWhile = true; for(int i=0;i<nStartPos.length;i++) { if(!fileSplitterFetch[i].bDownOver) { breakWhile = false; break; } } if(breakWhile) break; //count++; //if(count>4) // siteStop(); } System.err.println("文g下蝲l束Q?); } catch(Exception e){e.printStackTrace ();} } // 获得文g长度 public long getFileSize() { int nFileLength = -1; try{ URL url = new URL(siteInfoBean.getSSiteURL()); HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection (); httpConnection.setRequestProperty("User-Agent","NetFox"); int responseCode=httpConnection.getResponseCode(); if(responseCode>=400) { processErrorCode(responseCode); return -2; //-2 represent access is error } String sHeader; for(int i=1;;i++) { //DataInputStream in = new DataInputStream(httpConnection.getInputStream ()); //Utility.log(in.readLine()); sHeader=httpConnection.getHeaderFieldKey(i); if(sHeader!=null) { if(sHeader.equals("Content-Length")) { nFileLength = Integer.parseInt(httpConnection.getHeaderField(sHeader)); break; } } else break; } } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} Utility.log(nFileLength); return nFileLength; } // 保存下蝲信息Q文件指针位|)(j) private void write_nPos() { try{ output = new DataOutputStream(new FileOutputStream(tmpFile)); output.writeInt(nStartPos.length); for(int i=0;i<nStartPos.length;i++) { // output.writeLong(nPos[i]); output.writeLong(fileSplitterFetch[i].nStartPos); output.writeLong(fileSplitterFetch[i].nEndPos); } output.close(); } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} } // d保存的下载信息(文g指针位置Q? private void read_nPos() { try{ DataInputStream input = new DataInputStream(new FileInputStream(tmpFile)); int nCount = input.readInt(); nStartPos = new long[nCount]; nEndPos = new long[nCount]; for(int i=0;i<nStartPos.length;i++) { nStartPos[i] = input.readLong(); nEndPos[i] = input.readLong(); } input.close(); } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} } private void processErrorCode(int nErrorCode) { System.err.println("Error Code : " + nErrorCode); } // 停止文g下蝲 public void siteStop() { bStop = true; for(int i=0;i<nStartPos.length;i++) fileSplitterFetch[i].splitterStop(); } } </pre></td></tr></tbody></table><br /> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tbody> <tr> <td class="code-outline"><pre class="displaycode"> /* **FileSplitterFetch.java */ package NetFox; import java.io.*; import java.net.*; public class FileSplitterFetch extends Thread { String sURL; //File URL long nStartPos; //File Snippet Start Position long nEndPos; //File Snippet End Position int nThreadID; //Thread's ID boolean bDownOver = false; //Downing is over boolean bStop = false; //Stop identical FileAccessI fileAccessI = null; //File Access interface public FileSplitterFetch(String sURL,String sName,long nStart,long nEnd,int id) throws IOException { this.sURL = sURL; this.nStartPos = nStart; this.nEndPos = nEnd; nThreadID = id; fileAccessI = new FileAccessI(sName,nStartPos); } public void run() { while(nStartPos < nEndPos && !bStop) { try{ URL url = new URL(sURL); HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection (); httpConnection.setRequestProperty("User-Agent","NetFox"); String sProperty = "bytes="+nStartPos+"-"; httpConnection.setRequestProperty("RANGE",sProperty); Utility.log(sProperty); InputStream input = httpConnection.getInputStream(); //logResponseHead(httpConnection); byte[] b = new byte[1024]; int nRead; while((nRead=input.read(b,0,1024)) > 0 && nStartPos < nEndPos && !bStop) { nStartPos += fileAccessI.write(b,0,nRead); //if(nThreadID == 1) // Utility.log("nStartPos = " + nStartPos + ", nEndPos = " + nEndPos); } Utility.log("Thread " + nThreadID + " is over!"); bDownOver = true; //nPos = fileAccessI.write (b,0,nRead); } catch(Exception e){e.printStackTrace ();} } } // 打印回应的头信息 public void logResponseHead(HttpURLConnection con) { for(int i=1;;i++) { String header=con.getHeaderFieldKey(i); if(header!=null) //responseHeaders.put(header,httpConnection.getHeaderField(header)); Utility.log(header+" : "+con.getHeaderField(header)); else break; } } public void splitterStop() { bStop = true; } } /* **FileAccess.java */ package NetFox; import java.io.*; public class FileAccessI implements Serializable{ RandomAccessFile oSavedFile; long nPos; public FileAccessI() throws IOException { this("",0); } public FileAccessI(String sName,long nPos) throws IOException { oSavedFile = new RandomAccessFile(sName,"rw"); this.nPos = nPos; oSavedFile.seek(nPos); } public synchronized int write(byte[] b,int nStart,int nLen) { int n = -1; try{ oSavedFile.write(b,nStart,nLen); n = nLen; } catch(IOException e) { e.printStackTrace (); } return n; } } /* **SiteInfoBean.java */ package NetFox; public class SiteInfoBean { private String sSiteURL; //Site's URL private String sFilePath; //Saved File's Path private String sFileName; //Saved File's Name private int nSplitter; //Count of Splited Downloading File public SiteInfoBean() { //default value of nSplitter is 5 this("","","",5); } public SiteInfoBean(String sURL,String sPath,String sName,int nSpiltter) { sSiteURL= sURL; sFilePath = sPath; sFileName = sName; this.nSplitter = nSpiltter; } public String getSSiteURL() { return sSiteURL; } public void setSSiteURL(String value) { sSiteURL = value; } public String getSFilePath() { return sFilePath; } public void setSFilePath(String value) { sFilePath = value; } public String getSFileName() { return sFileName; } public void setSFileName(String value) { sFileName = value; } public int getNSplitter() { return nSplitter; } public void setNSplitter(int nCount) { nSplitter = nCount; } } /* **Utility.java */ package NetFox; public class Utility { public Utility() { } public static void sleep(int nSecond) { try{ Thread.sleep(nSecond); } catch(Exception e) { e.printStackTrace (); } } public static void log(String sMsg) { System.err.println(sMsg); } public static void log(int sMsg) { System.err.println(sMsg); } } /* **TestMethod.java */ package NetFox; public class TestMethod { public TestMethod() { ///xx/weblogic60b2_win.exe try{ SiteInfoBean bean = new SiteInfoBean("http://localhost/xx/weblogic60b2_win.exe", "L:\\temp","weblogic60b2_win.exe",5); //SiteInfoBean bean = new SiteInfoBean("http://localhost:8080/down.zip","L:\\temp", "weblogic60b2_win.exe",5); SiteFileFetch fileFetch = new SiteFileFetch(bean); fileFetch.start(); } catch(Exception e){e.printStackTrace ();} } public static void main(String[] args) { new TestMethod(); } } </pre></td></tr></tbody></table><br /><!-- CMA ID: 53173 --><!-- Site ID: 10 --><!-- XSLT stylesheet used to transform this file: dw-document-html-6.0.xsl --><br /><img src ="http://www.aygfsteel.com/f6k66ve/aggbug/378940.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/f6k66ve/" target="_blank">askzs</a> 2012-05-23 15:13 <a href="http://www.aygfsteel.com/f6k66ve/archive/2012/05/23/378940.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax+Flash多文件上传之 FancyUpload的应?/title><link>http://www.aygfsteel.com/f6k66ve/archive/2010/06/07/322974.html</link><dc:creator>askzs</dc:creator><author>askzs</author><pubDate>Mon, 07 Jun 2010 07:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/f6k66ve/archive/2010/06/07/322974.html</guid><wfw:comment>http://www.aygfsteel.com/f6k66ve/comments/322974.html</wfw:comment><comments>http://www.aygfsteel.com/f6k66ve/archive/2010/06/07/322974.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/f6k66ve/comments/commentRss/322974.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/f6k66ve/services/trackbacks/322974.html</trackback:ping><description><![CDATA[<p style="text-indent: 24pt;"><span style="font-size: 12pt;">Ajax+Flash</span>多文件上传是一个开源的上传lgQ名U是<span style="font-size: 12pt;">F</span>ancyUploadQ其官方|址是:(x)<a >http://digitarald.de/project/fancyupload/</a>。这个组件仅仅是客户端的应用lgQ即与Q何服务器端的技术没有关p,服务器端可以采用M后台技术(如JSP、Servlet、ASP<span>{)(j)。应用该lg提供 l我们的最大的好处有如下几点(个h认ؓ(f)Q呵呵)(j)Q?br /> </span></p> 1<span style="font-family: Wingdings;"><span style="font: 7pt 'Times New Roman';">          </span></span>仅是客户端的应用lgQ服务器端可以采用Q何后台技?span style="font-family: Wingdings;"><span style="font: 7pt 'Times New Roman';">  </span></span>Q?span style="font-family: Wingdings;"><br /> </span>2<span style="font-family: Wingdings;"> </span>可以同时选择多个文gq行上传Q?span style="font-family: Wingdings;"><br /> </span><span style="font-family: Wingdings;">3<span style="font: 7pt 'Times New Roman';">         </span></span>以队列的形式排列要上传的文g和其相关信息Q如名称、大等Q;<span style="font-family: Wingdings;"><br /> 4<span style="font: 7pt 'Times New Roman';">         </span></span>可以讄要上传的文g个数、文件类型和文g大小Q?span style="font-family: Wingdings;"><br /> 5<span style="font: 7pt 'Times New Roman';">         </span></span>有上传进度显C, 直观Q实用)(j)Q?span style="font-family: Wingdings;"><br /> 6<span style="font: 7pt 'Times New Roman';">       </span></span>上传的过E中可以随时取消要上传的文gQ?span style="font-family: Wingdings;"><br /> 7<span style="font: 7pt 'Times New Roman';">       </span></span>q_独立性,׃使用flash<span>? 成熟?/span>AJAX框架QmootoolsQ可以避免对特定览器和服务器依赖!<span style="font-family: Wingdings;"><br /> 8<span style="font: 7pt 'Times New Roman';">        </span></span>使用单,文g体积!<span style="font-family: Wingdings;"><br /> 9</span>  表单无须讄enctype="multipart/form-data"<span><br clear="all" /> </span> <p><br /> </p> <img src ="http://www.aygfsteel.com/f6k66ve/aggbug/322974.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/f6k66ve/" target="_blank">askzs</a> 2010-06-07 15:46 <a href="http://www.aygfsteel.com/f6k66ve/archive/2010/06/07/322974.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>仿网易多附g上传功能http://www.aygfsteel.com/f6k66ve/archive/2010/06/04/322772.htmlaskzsaskzsFri, 04 Jun 2010 09:12:00 GMThttp://www.aygfsteel.com/f6k66ve/archive/2010/06/04/322772.htmlhttp://www.aygfsteel.com/f6k66ve/comments/322772.htmlhttp://www.aygfsteel.com/f6k66ve/archive/2010/06/04/322772.html#Feedback0http://www.aygfsteel.com/f6k66ve/comments/commentRss/322772.htmlhttp://www.aygfsteel.com/f6k66ve/services/trackbacks/322772.html
<html>   
<head>   
 
<title>Add Files</title>   
 
<style>   
 
a.addfile {   
 
background-image:url(http://p.mail.163.com/js31style/lib/0703131650/163blue/f1.gif);   
 
background-repeat:no-repeat;   
 
background-position:-823px -17px;   
 
display:block;   
 
float:left;   
 
height:20px;   
 
margin-top:-1px;   
 
position:relative;   
 
text-decoration:none;   
 
top:0pt;   
 
width:80px;   
 
}   
 
 
 
input.addfile {   
 
/*left:-18px;*/  
 
}   
 
 
 
input.addfile {   
 
cursor:pointer !important;   
 
height:18px;   
 
left:-13px;   
 
filter:alpha(opacity=0);    
 
position:absolute;   
 
top:5px;   
 
width:1px;   
 
z-index: -1;   
 
}   
 
</style>   
 
 
 
<script type="text/javascript">   
 
 
 
function MultiSelector(list_target, max)   
 
{   
 
    // Where to write the list   
 
    this.list_target = list_target;   
 
    // How many elements?   
 
    this.count = 0;   
 
    // How many elements?   
 
    this.id = 0;   
 
    // Is there a maximum?   
 
    if (max)   
 
    {   
 
        this.max = max;   
 
    }    
 
    else    
 
    {   
 
        this.max = -1;   
 
    };   
 
 
 
    /**  
 
     * Add a new file input element  
 
     */  
 
    this.addElement = function(element)   
 
    {   
 
        // Make sure it's a file input element   
 
        if (element.tagName == 'INPUT' && element.type == 'file')   
 
        {   
 
            // Element name -- what number am I?   
 
            element.name = 'file_' + this.id++;   
 
 
 
            // Add reference to this object   
 
            element.multi_selector = this;   
 
 
 
            // What to do when a file is selected   
 
            element.onchange = function()   
 
            {   
 
                // New file input   
 
                var new_element = document.createElement('input');   
 
                new_element.type = 'file';   
 
                new_element.size = 1;   
 
                new_element.className = "addfile";   
 
 
 
                // Add new element   
 
                this.parentNode.insertBefore(new_element, this);   
 
 
 
                // Apply 'update' to element   
 
                this.multi_selector.addElement(new_element);   
 
 
 
                // Update list   
 
                this.multi_selector.addListRow(this);   
 
 
 
                // Hide this: we can't use display:none because Safari doesn't like it   
 
                this.style.position = 'absolute';   
 
                this.style.left = '-1000px';   
 
            };   
 
 
 
 
 
            // If we've reached maximum number, disable input element   
 
            if (this.max != -1 && this.count >= this.max)   
 
            {   
 
                element.disabled = true;   
 
            };   
 
 
 
            // File element counter   
 
            this.count++;   
 
            // Most recent element   
 
            this.current_element = element;   
 
        }    
 
        else    
 
        {   
 
            // This can only be applied to file input elements!   
 
            alert('Error: not a file input element');   
 
        };   
 
    };   
 
 
 
 
 
    /**  
 
     * Add a new row to the list of files  
 
     */  
 
    this.addListRow = function(element)   
 
    {   
 
        // Row div   
 
        var new_row = document.createElement('div');   
 
 
 
        // Delete button   
 
        var new_row_button = document.createElement('input');   
 
        new_row_button.type = 'button';   
 
        new_row_button.value = 'Delete';   
 
 
 
        // References   
 
        new_row.element = element;   
 
 
 
        // Delete function   
 
        new_row_button.onclick = function()   
 
        {   
 
            // Remove element from form   
 
            this.parentNode.element.parentNode.removeChild(this.parentNode.element);   
 
 
 
            // Remove this row from the list   
 
            this.parentNode.parentNode.removeChild(this.parentNode);   
 
 
 
            // Decrement counter   
 
            this.parentNode.element.multi_selector.count--;   
 
 
 
            // Re-enable input element (if it's disabled)   
 
            this.parentNode.element.multi_selector.current_element.disabled = false;   
 
 
 
            // Appease Safari   
 
            // without it Safari wants to reload the browser window   
 
            // which nixes your already queued uploads   
 
            return false;   
 
        };   
 
 
 
        // Set row value   
 
        new_row.innerHTML = element.value + " ";   
 
 
 
        // Add button   
 
        new_row.appendChild(new_row_button);   
 
 
 
        // Add it to the list   
 
        this.list_target.appendChild(new_row);   
 
    };   
 
};   
 
</script>   
 
</head>   
 
 
 
<body>   
 
 
 
<!-- This is the form -->   
 
<form enctype="multipart/form-data" action="http://127.0.0.1:8080/zzgh/cx/upload.jsp" method="post">   
 
<!-- The file element -- NOTE: it has an ID -->   
 
<a href="javascript:void(1==1);" class="addfile" style="cursor: default;" hidefocus="true">   
 
<input id="my_file_element" class="addfile" type="file" name="file_1" size="1" title="点击选择附g">   
 
</a>   
 
<input type="submit" value="??>   
 
</form>   
 
 
 
Files:   
 
<!-- This is where the output will appear -->   
 
<div id="files_list" style="padding:5px;border:1px;border-style:solid;border-color:#0000ff;height:100px;width:600px;"></div>   
 
<script>   
 
<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->   
 
var multi_selector = new MultiSelector(document.getElementById('files_list'), 100);   
 
<!-- Pass in the file element -->   
 
multi_selector.addElement(document.getElementById('my_file_element'));   
 
</script>   
</body>   
 
</html> 


效果囑֦下:(x)





askzs 2010-06-04 17:12 发表评论
]]>
JSP应用导出Excel报表的简单实C?qing)中文ؕ码彻底解冻IHTMLQ?http://www.aygfsteel.com/f6k66ve/archive/2010/05/12/320750.htmlaskzsaskzsWed, 12 May 2010 14:06:00 GMThttp://www.aygfsteel.com/f6k66ve/archive/2010/05/12/320750.htmlhttp://www.aygfsteel.com/f6k66ve/comments/320750.htmlhttp://www.aygfsteel.com/f6k66ve/archive/2010/05/12/320750.html#Feedback0http://www.aygfsteel.com/f6k66ve/comments/commentRss/320750.htmlhttp://www.aygfsteel.com/f6k66ve/services/trackbacks/320750.html一Q先新徏一个excel文gQ调整格式(是你所惌昄的格式)(j)Q?br /> 二,把刚才新建的excel文g令存?htmlQdemo.htmlQ文Ӟ
三,新徏一个jsp面Q?在该JSP面头部讄response的ContentType为Excel格式
<% response.setContentType("application/vnd.ms-excel;charset=GBK"); %>
然后讄|页资料是以excel报表以线上浏览方式呈现或者是下蝲的方式呈?br /> <%
/ /q行讑֮传送到前端览器时的档名ؓ(f)test1.xls  是靠这一行,让前端浏览器以ؓ(f)接收C个excel?nbsp;
 //网资料以excel报表以线上浏览方式呈?
response.setHeader("Content-disposition","inline; filename=test1.xls");
   //网资料以下蝲的方?br /> response.setHeader("Content-disposition","attachment; filename=test2.xls");
%>
然后?nbsp;demo.html的源代码_脓(chung)在jsp面Q如?br />

<%@ page contentType="text/html; charset=GBK" %>
<% response.setContentType("application/vnd.ms-excel;charset=GBK");
response.setHeader("Content-disposition","attachment; filename=test2.xls");

%>
<!--以下Z持成html面的excel的内?demo.html面-->
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<link rel=File-List href="qwe.files/filelist.xml">
<link rel=Edit-Time-Data href="qwe.files/editdata.mso">
<link rel=OLE-Object-Data href="qwe.files/oledata.mso">
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Created>1996-12-17T01:32:42Z</o:Created>
  <o:LastSaved>2010-05-12T13:59:04Z</o:LastSaved>
  <o:Version>11.9999</o:Version>
 </o:DocumentProperties>
 <o:OfficeDocumentSettings>
  <o:RemovePersonalInformation/>
 </o:OfficeDocumentSettings>
</xml><![endif]-->
<style>
<!--table
 {mso-displayed-decimal-separator:"\.";
 mso-displayed-thousand-separator:"\,";}
@page
 {margin:1.0in .75in 1.0in .75in;
 mso-header-margin:.5in;
 mso-footer-margin:.5in;}
tr
 {mso-height-source:auto;
 mso-ruby-visibility:none;}
col
 {mso-width-source:auto;
 mso-ruby-visibility:none;}
br
 {mso-data-placement:same-cell;}
.style0
 {mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 white-space:nowrap;
 mso-rotate:0;
 mso-background-source:auto;
 mso-pattern:auto;
 color:windowtext;
 font-size:12.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 border:none;
 mso-protection:locked visible;
 mso-style-name:常规;
 mso-style-id:0;}
td
 {mso-style-parent:style0;
 padding-top:1px;
 padding-right:1px;
 padding-left:1px;
 mso-ignore:padding;
 color:windowtext;
 font-size:12.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 border:none;
 mso-background-source:auto;
 mso-pattern:auto;
 mso-protection:locked visible;
 white-space:nowrap;
 mso-rotate:0;}
ruby
 {ruby-align:left;}
rt
 {color:windowtext;
 font-size:9.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 mso-char-type:none;
 display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet1</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:CodeName>Sheet1</x:CodeName>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveCol>1</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:CodeName>Sheet2</x:CodeName>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet3</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:CodeName>Sheet3</x:CodeName>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>4530</x:WindowHeight>
  <x:WindowWidth>8505</x:WindowWidth>
  <x:WindowTopX>480</x:WindowTopX>
  <x:WindowTopY>120</x:WindowTopY>
  <x:AcceptLabelsInFormulas/>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>

<body link=blue vlink=purple>

<table x:str border=0 cellpadding=0 cellspacing=0 width=288 style='border-collapse:
 collapse;table-layout:fixed;width:216pt'>
 <col width=72 span=4 style='width:54pt'>
 <tr height=19 style='height:14.25pt'>
  <td height=19 width=72 style='height:14.25pt;width:54pt'>全球</td>
  <td width=72 style='width:54pt'>问问</td>
  <td width=72 style='width:54pt'>ee</td>
  <td width=72 style='width:54pt'>rr</td>
 </tr>
 <tr height=19 style='height:14.25pt'>
  <td height=19 style='height:14.25pt'>暗暗</td>
  <td>ss</td>
  <td>dd</td>
  <td>ff</td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=72 style='width:54pt'></td>
  <td width=72 style='width:54pt'></td>
  <td width=72 style='width:54pt'></td>
  <td width=72 style='width:54pt'></td>
 </tr>
 <![endif]>
</table>

</body>

</html>


中文问题Q?br /> 查看源代码时发现JSP文g中写ȝ中文Zؕ码,则在JSP文g头部d一?br /> <%@ page contentType="text/html; charset=gb2312" %>
查看源代码时发现文字Z文,但是用Excel打开Zؕ码则?lt;html>?lt;head>中加?br /> <meta http-equiv="Content-Type" content="text/html; charset=GBK">

在jsp面中,要在excel中显C的内容可以从数据库中读取,在此׃做详l的介绍?/p>

askzs 2010-05-12 22:06 发表评论
]]>
tomcat 不显C目录列表(在没有默认文件的时候)(j)http://www.aygfsteel.com/f6k66ve/archive/2010/02/26/314025.htmlaskzsaskzsFri, 26 Feb 2010 09:28:00 GMThttp://www.aygfsteel.com/f6k66ve/archive/2010/02/26/314025.htmlhttp://www.aygfsteel.com/f6k66ve/comments/314025.htmlhttp://www.aygfsteel.com/f6k66ve/archive/2010/02/26/314025.html#Feedback0http://www.aygfsteel.com/f6k66ve/comments/commentRss/314025.htmlhttp://www.aygfsteel.com/f6k66ve/services/trackbacks/314025.html   <servlet>  
                  <servlet-name>default</servlet-name>  
                  <servlet-class>  
                      org.apache.catalina.servlets.DefaultServlet  
                  </servlet-class>  
                  <init-param>  
                          <param-name>debug</param-name>  
                          <param-value>0</param-value>  
                  </init-param>  
                  <init-param>  
                          <param-name>listings</param-name>  
                          <param-value>true</param-value>  
                  </init-param>  
                  <load-on-startup>1</load-on-startup>  
          </servlet>  
  把里面的  
                  <init-param>  
                          <param-name>listings</param-name>  
                          <param-value>true</param-value>  
                  </init-param>  
  true改ؓ(f)false

askzs 2010-02-26 17:28 发表评论
]]>
关于web.xml中的<welcome-file>http://www.aygfsteel.com/f6k66ve/archive/2010/02/26/askzs.htmlaskzsaskzsFri, 26 Feb 2010 09:19:00 GMThttp://www.aygfsteel.com/f6k66ve/archive/2010/02/26/askzs.htmlhttp://www.aygfsteel.com/f6k66ve/comments/314024.htmlhttp://www.aygfsteel.com/f6k66ve/archive/2010/02/26/askzs.html#Feedback0http://www.aygfsteel.com/f6k66ve/comments/commentRss/314024.htmlhttp://www.aygfsteel.com/f6k66ve/services/trackbacks/314024.html最q有个工E,需要把HnSp文g下的index.html作ؓ(f)默认面Q目录结构如下)(j)Q?br />


我在web.xml中设|?lt;welcome-file>HnSp/index.html</welcome-file>,可是前台index.html

能显C出来,可是面中的囄都显CZ出来Qindex.html中的囄的\径都是用的相对\

径)(j)Q后来在发现昄的页面中的图片少?jin)一U,在图片的路径前加入HnSpp正确昄?/p>

Q可是在别的面通过链接讉Kindex.html面Q图片还是显CZ出来Q看?jin)知道,多?jin)?/p>

HnSpQ看来在囄的\径前加入HnSp是不对的Q?br /> 我一直想不懂Z么,后来想了(jin)个办法解决了(jin)Q就是在WebRoot下新Z个新的空面

MyJspjspQ写入如下代?<%response.sendRedirect("HnSp/index.html"); %>Q然后把   

<welcome-file>HnSp/index.html</welcome-file>,改ؓ(f)<welcome-

file>MyJsp.jsp</welcome-file>,q样问题p决了(jin)Q都不存在\径错误问题了(jin)Q?/p>

response.sendRedirect()

是在用户的浏览器端工?sendRedirect()可以带参C?比如servlet?name=frank传至?/p>

个页?同时它可以重定向至不同的L?sendRedirect()可以重定向有frame.的jsp文g.

重定向后在浏览器地址栏上?x)出现重定向面的URLQ由于response是jsp面中的隐含对象

Q故在jsp面中可以用response.sendRedirect()直接实现重定位?br />



askzs 2010-02-26 17:19 发表评论
]]>
վ֩ģ壺 | | ƽ| ͩ| | | | ʡ| ʡ| °Ͷ| | Ȫ| ޵| | | | | | | | Ȫ| | ׳| ľ| ƺ| | ˮ| | ǿ| ϼ| | | | â| | | | | ɽʡ| ϴ| |