freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

jspsmartupload是由wwwjspsmartcom-資料下載頁(yè)

2025-06-24 00:57本頁(yè)面
  

【正文】 組件進(jìn)行了研究,發(fā)現(xiàn)對(duì)返回給瀏覽器的另存文件名進(jìn)行UTF8編碼后,瀏覽器便能正確顯示中文名字了。這是一個(gè)令人高興的發(fā)現(xiàn)。于是我對(duì)jspSmartUpload組件的SmartUpload類做了升級(jí)處理,增加了toUtf8String這個(gè)方法,改動(dòng)部分源碼如下:public void downloadFile(String s, String s1, String s2, int i)throws ServletException, IOException, SmartUploadException{if(s == null)throw new IllegalArgumentException(File 39。 + s +39。 not found (1040).)。if(())throw new IllegalArgumentException(File 39。 + s +39。 not found (1040).)。if(!isVirtual(s) amp。amp。 m_denyPhysicalPath)throw new SecurityException(Physical path isdenied (1035).)。if(isVirtual(s))s = (s)。 file = new (s)。FileInputStream fileinputstream = new FileInputStream(file)。long l = ()。boolean flag = false。int k = 0。byte abyte0[] = new byte[i]。if(s1 == null)(application/xmsdownload)。elseif(() == 0)(application/xmsdownload)。else(s1)。((int)l)。m_contentDisposition = m_contentDisposition != null ?m_contentDisposition : attachment。if(s2 == null)(ContentDisposition,m_contentDisposition + filename= +toUtf8String(getFileName(s)))。elseif(() == 0)(ContentDisposition,m_contentDisposition)。else(ContentDisposition,m_contentDisposition + filename= + toUtf8String(s2))。8. while((long)k l){int j = (abyte0, 0, i)。k += j。().write(abyte0, 0, j)。}()。}/*** 將文件名中的漢字轉(zhuǎn)為UTF8編碼的串,以便下載時(shí)能正確顯示另存的文件名.* * @param s 原文件名* @return 重新編碼后的文件名*/public static String toUtf8String(String s) {StringBuffer sb = new StringBuffer()。for (int i=0。i()。i++) {char c = (i)。if (c = 0 amp。amp。 c = 255) {(c)。} else {byte[] b。try {b = (c).getBytes(utf8)。} catch (Exception ex) {(ex)。b = new byte[0]。}for (int j = 0。 j 。 j++) {int k = b[j]。if (k 0) k += 256。(% + (k).toUpperCase())。}}}return ()。}注意源碼中粗體部分,原jspSmartUpload組件對(duì)返回的文件未作任何處理,現(xiàn)在做了編碼的轉(zhuǎn)換工作,將文件名轉(zhuǎn)換為UTF8形式的編碼形式。UTF8編碼對(duì)英文未作任何處理,對(duì)中文則需要轉(zhuǎn)晃?XX的形式。toUtf8String方法中,直接利用Java語(yǔ)言提供的編碼轉(zhuǎn)換方法獲得漢字字符的UTF8編碼,之后將其轉(zhuǎn)換為%XX的形式。,拷貝到Tomcat的shared/lib目錄下(可為所有WEB應(yīng)用程序所共享),然后重啟Tomcat服務(wù)器就可以正常下載含有中文名字的文件了。另,toUtf8String方法也可用于轉(zhuǎn)換含有中文的超級(jí)鏈接,以保證鏈接的有效,因?yàn)橛械腤EB服務(wù)器不支持中文鏈接。小結(jié):jspSmartUpload組件是應(yīng)用JSP進(jìn)行B/S程序開(kāi)發(fā)過(guò)程中經(jīng)常使用的上傳下載組件,它使用簡(jiǎn)單,方便?,F(xiàn)在我又為其加上了下載中文名字的文件的支持,真?zhèn)€是如虎添翼,必將贏得更多開(kāi)發(fā)者的青睞。24 / 24
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)教案相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1