1、get是從服務器上取得數據,post是向服務器上傳送數據。
2、get是將參數數據隊列(表單)加到提交表單的action所指定的url中,值和表單的各個字段是相互對應的,Get將表單中數據的按照variable=value的形式,添加到action所指向的URL后面,并且兩者使用“?”連接,而各個變量之間使用“&”連接,在url中是可以看見的,
post是將表單各個字段放在http header內一起傳送到action中的URL中,
3、get,服務器通過request.getQuery()獲得對應的值;對于post,服務器通過request.getForm()表單的值。
4、get,傳送的數據小,post,傳送的數據大,上傳文件一般用post
特別注意:
<form action="/GraAppInfo/GraAppInfo.do?method=UpList"? method="post">
<select name="srchType">
???? <option value="0">名字</option>
???? <option value="1">用人單位</option>
???</select>
???<input height="18" name="srchEdit" type="text" align="right">
? <input? type="submit" value="查詢">
顯示的URL:http://localhost:8080/GraAppInfo/GraAppInfo.do?method=UpList
<form action="/GraAppInfo/GraAppInfo.do?method=UpList"? method="get">
顯示的URL:http://localhost:8080/GraAppInfo/GraAppInfo.do?srchType=0&srchEdit=da
可見post 會覆蓋action中的參數,
5、中文用post傳遞不會出現亂碼,用get傳遞會出現亂碼
所以傳到action后要通過
String srchEdit = new String(graForm.getSrchEdit().getBytes("iso8859-1"), "gb2312");
處理。
二、傳到頁面的值亂碼