get和post请求方式的区别
* 请求的时机
* 什么情况下是get请求方式
* 在地址栏直接输入路径 此时的请求方式是get
http://localhost:808/test03/a.html
* a标签使用的请求方式是get
<a href="./b.html>test</a>
* 表单的method属性值为get,此时的请求方式是get
<form action="" method="get">
<input type="text" name="username"><br>
<input type="text" name="tel"><br>
<input type="submit" value="提交"><br>
</form>
* 什么情况下post的请求方式
* 表单的method属性值为post,此时的请求方式是post
<form action="" method="post">
<input type="text" name="username"><brg >
<input type="text" name="tel"><br>
<input type="submit" value="提交"><br>
</form>
* 区别:
* 传递的数据量
* get请求方式,传递的数据量小,不能超过1k
* post方式传递无限制的数据量, 传递的数据量大
* 地址栏的变化:
* 表单如下
<form name="form1" action="./formGetPost" method="GET">
用户名:<input type="text" name="username" value="123"><br>
密码:<input type="password" name="psw"><br>
<input type="submit" value="保存"><br>
</form>
* 如果请求为get 当点击" 按钮 "
* 表单参数的值作为请求的路径的参数形式传递,地址的路径发生变化
http://localhost:808/day05/formGetPost?username=123&psw=456
* 如果请求为post 当点击" 按钮 "
* 表单参数的值不会放置到路径的后,作为请求的正文传递
* 表单参数的名和路径后参数的名称相同情况下;
* 表单如下
<form name="form1" action="./formGetPost?username=999" method="get">
用户名:<input type="text" name="username" value="123"><br>
密码:<input type="password" name="psw"><br>
<input type="submit" value="保存"><br>
</form>
* 如果表单的请求方法是get,则 表单username的值覆盖路径参数中username的值./formGetPost?username=999
在servlet中获取的是表单username的值
* 如果表单的请求方法是post,则 表单username的值此时作为正文传递.而路径后的username还是作为参数传递
在servlet中获取的是表单username的值和路径后的username的值
* 传递参数的方式:
http://localhost:808/test03/a.html?参数名1=参数值1&参数名2=参数值2
http://localhost:808/test03/a.html?username=zhang&psw=123456