The get and post methods in the form suffer a lot. I am learning by doing, and I can't understand it just by looking at the theory.

After the Mid-Autumn Festival came back, he had a sullen expression, and he had no love for life without enough sleep. . .

In the morning, I was changing the query, and I always couldn't find what I wanted when I entered a query. . . The interrupt point looked at and was about to fall asleep, and found that the method name was the same, and the passed parameters were different, resulting in incorrect data queried. . . . After changing it, it still doesn't work. . .

At one o'clock in the afternoon, the property with the same name was acquired on the page, and the mystery was finally solved. . It turned out to be in the wrong direction at first, but it was fixed in a few minutes. . . It is found that after entering a Chinese query, the returned page is garbled: [???ú???÷] is amazing. . . .

Attempts made:

1. Modify apache-tomcat-7.0.69\conf\server.xml in tomcat to put the port number

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

Added [ URIEncoding="GBK" ]

改为: <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="GBK"/>

result: invalid

2. Modify the encode on the page

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

改为:<meta http-equiv="Content-Type" content="text/html; charset=GBK" />

result: invalid

3. Check the method="" in the anction in the form

 <form action="#getRequestUri()" method="get" name="voiceQueryForm" id="voiceQueryForm">

改为: <form action="#getRequestUri()" method="post" name="voiceQueryForm" id="voiceQueryForm">

Result: normal


Supplementary knowledge point: What is the difference between get and post in form? ? ? ? Baidu a bit (╮(╯▽╰)╭ can’t do without Du Niang)

I picked a 360 answer, which is simpler.

The get post method in the FORM is different from the get and post methods in the Form, which correspond to the GET and POST methods in the HTTP protocol respectively during the data transmission process.

The main differences between the two are as follows: 

1. Get is used to obtain data from the server, and Post is used to transfer data to the server. 

2. Get adds the data in the form to the URL pointed to by the action in the form of variable=value, and uses "?" to connect the two, and "&" to connect each variable; The data is placed in the data body of the form, and is passed to the URL pointed to by the action according to the corresponding method of variables and values.  

3、 Get是不安全的,因为在传输过程,数据被放在请求的URL中,而如今现有的很多服务器、代理服务器或者用户代理都会将请求URL记录到日志文件中,然后 放在某个地方,这样就可能会有一些隐私的信息被第三方看到。另外,用户也可以在浏览器上直接看到提交的数据,一些系统内部消息将会一同显示在用户面前。 Post的所有操作对用户来说都是不可见的。  

4、Get传输的数据量小,这主要是因为受URL长度限制;而Post可以传输大量的数据,所以在上传文件只能使用Post(当然还有一个原因,将在后面的提到)。  

5、Get限制Form表单的数据集的值必须为ASCII字符;而Post支持整个ISO10646字符集。  

6、Get是Form的默认方法。

若是不遇到,当年学的东西基本如数归还给课本。。。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325787695&siteId=291194637