Detailed explanation of Java programming post data request and receiving code

In the past two days, the HTTP server has made requests. After the client post data to the server, the server passes request Getparameter() made a request and could not read the data. After searching, it was found that the data could not be read because it was set to text / plain mode

If it is set in the following way, you can use request Getparameter () can read the data

Three codes of enctype

The enctype attribute in the form can be used to control how to encode the form data before sending it, that is, all characters will be encoded before sending it to the server (spaces are converted to "+" plus signs, and special symbols are converted to asciihex values). The default is application / x-www-form-urlencoded.

Multipart / form data is used to send binary files. The other two types cannot be used to send files

Text / plain is used to send plain text content without encoding special characters. It is generally used for email and so on.

The difference between application / x-www-form-urlencoded and text / plain is that one sends HTML content and the other sends plain text content

Application / x-www-form-urlencoded encodes all characters before sending (default)

Multipart / form data does not encode characters. This value must be used when using a form that contains a file upload control.

Text / plain spaces are converted to a "+" plus sign, but special characters are not encoded.

When the enctype is defined as application / x-www-form-urlencoded, the following methods are used to receive data

When the enctype is defined as text / plain, the following methods are used to receive data

Post and get

TP requests are supported in almost all programming languages. We often use two kinds: get and post requests. In general, sending a get request is very simple, because the parameters are directly placed on the request URL. For post requests, the data is sent in the message body, so it is relatively troublesome. When it comes to binary data types such as files, it needs more processing.

Post and get can transfer parameters through key value pairs, and the server can transfer parameters through request Request to obtain data in getparameter mode.

The client sends the post data to the server, and the server receives and processes it

summary

The above is all about the detailed explanation of Java programming post data request and receiving code in this article. I hope it will be helpful to you. Interested friends can continue to refer to this website:

Popular explanation and code example of communication between Java threads

Java multithreading thread communication producer consumer mode and waiting wake-up mechanism code explanation

Java multithreading programming socket communication example code

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
分享
二维码
< <上一篇
下一篇>>