get和post兩種提交方式的區 別

提交方式: get提交。
地 址 欄 :
http://10.1.31.69:9090/?user=abc&psw=123&repsw=123&sex=nan&tech=java&tech=html&c
ountry=cn
GET /?user=abc&psw=123&repsw=123&sex=nan&tech=java&tech=html&country=cn HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, /
Accept-Language: zh-cn,zu;q=0.5
Accept-Encoding: gzip, deflate
323
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)
Host: 10.1.31.69:9090
Connection: Keep-Alive
提交方式: POST
地址欄: http://10.1.31.69:9090/
POST / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, /
Accept-Language: zh-cn,zu;q=0.5
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)
Host: 10.1.31.69:9090
Content-Length: 68
Connection: Keep-Alive
Cache-Control: no-cache
user=hahah&psw=8989&repsw=8989&sex=nv&tech=html&tech=css&country=usa
GET提交和POST提交的區別?
1,
get提交,提交的信息都顯示在地址欄中。
post提交,提交的信息不顯示地址欄中。
2,
get提交,對於敏感的數據信息不安全。
post提交,對於敏感信息安全。
3,
get提交,對於大數據不行,因爲地址欄存儲體積有限。
post提交,可以提交大體積數據。
4,
get提交,將信息封裝到了請求消息的請求行中。
post提交,將信息封裝到了請求體中。
在服務端的一個區別。
如果出現將中文提交到tomcat服務器,服務器默認會用iso8859-1進行解碼會出現亂碼,
通過iso8859-1進行編碼, 再用指定的中文碼錶解碼即可。
這種方式對get提交和post提交都有效。
324
但是對於post提交方式提交的中文,還有另一種解決辦法,就是直接使用服務端一個對象
request對象的setCharacterEncoding方法直接設置指定的中文碼錶就可以將中文數據解析出
來。
這個方法只對請求體中的數據進行解碼。
綜上所述:表單提交,建議使用post。
和服務端交互的三種方式:
1,地址欄輸入url地址。 get
2,超鏈接。 get
3,表單。 get 和 post
如果在客戶端進行增強型的校驗(只要有一個組件內容是錯誤,是無法繼續提交的, 只有全對纔可以提交)
問,服務端收到數據後,還需要校驗嗎?
答: 需要,爲了安全性。
如果服務端做了增強型的校驗,客戶端還需要校驗嗎?
答: 需要,因爲要提高用戶的上網體驗效果,減輕服務器端的壓力。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<!--meta http-equiv="refresh" content="3;url=http://www.sina.com.cn" /-->
<title>Untitled Document</title>
</head>
<body>
<form action="http://10.1.31.69:9090" method="post">
<table border="1" bordercolor="#0000ff" cellpadding=10 cellspacing=0
width=600>
<tr>
<th colspan="2">註冊表單</th>
</tr>
<tr>
<td>用戶名稱: </td>
<td><input type="text" name="user" /></td>
</tr>
<tr>
<td>輸入密碼: </td>
<td><input type="password" name="psw" /></td>
</tr>
<tr>
<td>確認密碼: </td>
<td><input type="password" name="repsw" /></td>
</tr>
<tr>
<td>選擇性別: </td>
<td>
<input type="radio" name="sex" value="nan" /><input type="radio" name="sex" value="nv" />女
325
</td>
</tr>
<tr>
<td>選擇技術: </td>
<td>
<input type="checkbox" name="tech" value="java" />JAVA
<input type="checkbox" name="tech" value="html" />HTML
<input type="checkbox" name="tech" value="css" />CSS
</td>
</tr>
<tr>
<td>選擇國家: </td>
<td>
<select name="country">
<option value="none">--選擇國家--</option>
<option value="usa">--美國--</option>
<option value="en">--英國--</option>
<option value="cn">--中國--</option>
</select>
</td>
</tr>
<tr>
<th colspan="2">
<input type="reset" value="清除數據" />
<input type="submit" value="提交數據" />
</th>
</tr>
</table>
</form>
</body>
</html>
發佈了86 篇原創文章 · 獲贊 10 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章