Ajax Download Smartupload content cannot display Chinese character solution _ajax related

Source: Internet
Author: User
Copy Code code as follows:

Server side:
public void Doget (HttpServletRequest req, HttpServletResponse resp)
Throws Servletexception, ioexception{
Req.setcharacterencoding ("GBK");
Create a new Smartupload object
Smartupload su = new Smartupload ();
Su.initialize (This.getservletconfig (), REQ,RESP);
Set contentdisposition NULL to prevent the browser from automatically opening the file.
Ensure that you click on the link to download the file. If not set, the downloaded file name extension is
Doc, the browser will automatically open it in Word. When the extension is PDF,
The browser will be opened with Acrobat.

Su.setcontentdisposition (NULL);
Download files
try {
Su.downloadfile ("d://upload/" + "test.txt");
catch (Smartuploadexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}



Copy Code code as follows:

Client:
<script>
function GetFile () {
$.get ("<%=basepath%>loadfileservlet", "" ", function (data) {
alert (data);
});
}
</script>
<a href= "#" onclick= "GetFile ()" >getfile</a>



txt in Chinese content does not show, if through the hyperlink access to the server side, download no garbled





, Mark, look at it later.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.