About HTTPCLIENT upload files is the process of Chinese name

xiaoxiao2021-03-06  111

In a project, the upload file uses httpclient to post file. It is found in the test if the file is a Chinese name. The uploaded file is garbled and found in the httpclient, which is ASCII, so for garbled org / apache / EncodingUtil.java / ** * Converts the specified string to byte array of ASCII characters at commons / httpclient / util package. * * @param data the string to be encoded * @return the string as a byte array. * * @since 3.0 * / Public static Byte [] getasciibytes (Final String Data) {

IF (DATA == Null) {throw new illegalargumentException ("Parameter May Not Be Null);

try {return data.getBytes ( "US-ASCII");} catch (UnsupportedEncodingException e) {throw new HttpClientError ( "HttpClient requires ASCII support");}} Solution: 1 ascii data processing at the receiving end 2 recompiled package httpclient , That is, change the above method, change to ISO8859-1 or UTF-8, can solve the problem of "HTTPCLIENT is a good method, you can give you another system POST data, like the INDY control in Delphi,

转载请注明原文地址:https://www.9cbs.com/read-104403.html

New Post(0)