欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ajax下載smartupload的內(nèi)容無(wú)法顯示漢字的解決方法

 更新時(shí)間:2013年11月20日 16:52:39   作者:  
用ajax下載smartupload的內(nèi)容無(wú)法顯示漢字情況,大有人遇到,下面給出服務(wù)器端以及客戶端上的解決方案,感興趣的朋友不要錯(cuò)過(guò)
復(fù)制代碼 代碼如下:

服務(wù)器端:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException{
req.setCharacterEncoding("GBK");
// 新建一個(gè)SmartUpload對(duì)象
SmartUpload su = new SmartUpload();
su.initialize(this.getServletConfig(),req,resp);
// 設(shè)定contentDisposition為null以禁止瀏覽器自動(dòng)打開(kāi)文件,
//保證點(diǎn)擊鏈接后是下載文件。若不設(shè)定,則下載的文件擴(kuò)展名為
//doc時(shí),瀏覽器將自動(dòng)用word打開(kāi)它。擴(kuò)展名為pdf時(shí),
//瀏覽器將用acrobat打開(kāi)。

su.setContentDisposition(null);
//下載文件
try {
su.downloadFile("D://upload/"+"test.txt");
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

復(fù)制代碼 代碼如下:

客戶端:
<script>
function getFile(){
$.get("<%=basePath%>LoadFileServlet","",function(data){
alert(data);
});
}
</script>
<a href="#" onclick="getFile()">getfile</a>

txt中的中文內(nèi)容不顯示,如果通過(guò)超鏈接訪問(wèn)server端,下載后沒(méi)有亂碼

先MARK下,以后再看看

相關(guān)文章

最新評(píng)論