Java implements form submission (supports simultaneous uploading of multiple files)

In Android or J2EE, it is necessary to lie on other people's website data. It is very common to simulate form submission. However, it may be a little difficult to upload multiple files and ordinary form fields in Android. Today, I took the time to sort out a tool class, mainly with the help of httpclient, which is actually very simple, It's very clear when you look at the code

Httpclient tool class:

HttpClientUtil. java

Methods to upload files and read parameters on the server side: (with the help of Apache's fileUpload component, it realizes three field acquisition methods: directly splicing parameters behind form action, form common item and file item)

I wrote a servlet directly in the background. The specific code is as follows:

ServletUploadFile. java

The tool class and server-side code are posted on it. You don't need to say how to call it? The packaging is clear enough

Call example Demo:

Finally, let's explain the jar problem:

If it is applied in Android, you should pay attention to the introduction of httpmime-4.3 1. Jar (the version I downloaded at that time was the highest version). As for the jar of fileUpload, go directly to the official Apache website to download it

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>