First, I wrote a java project test to send a post request: it can contain text parameters and file parameters ********************************* *******************
Copy code
The above code can successfully simulate a java client to send a post request, and the server can also receive and save files
The main method for java testing:
Copy code
I thought it was done. As a result, it was no problem to compile the program after it was transplanted to the android project.
However, if an exception is thrown during the runtime, The PostMethod class cannot be found. The org. apache. commons. httpclient. methods. PostMethod class is definitely included;
Another exception is VerifyError. I am helpless when I encounter this exception several times during development. I think the SDK is incompatible or not. Can anyone tell me ~~
As a result, I have directly analyzed the content of the http request on the Internet to build a post request, and I have also found that the content with the uploaded file is always a problem, you can directly run the post request sent by the java project above, print the request content in the servlet, and finally implement it against the concatenated string and stream! The Code is as follows:
**************************************** *******************
Copy code
**********************
Code in the button response:
**********************
Copy code
***************************
Server servlet code:
***************************