GET请求和POST请求
特点: a.在URL地址后面附加参数;
b.传送数据量是有限的,一般限制在1KB一下。
代码:
<form action="/loginServlet" method="get">
user: <input type="text" name="user"/>
password: <input type="password" name="password"/>
<input type="submit" value="Submit"/> </form>
a. 在浏览器地址栏中输入某个URL地址或单机网页上的一个超链接时,浏览器发出的HTTP请求消息 的请求方式为GET;
b. 如果网页中的<form>表单元素的method属给性被设置为“get”,浏览器提交这个FORM表单时生成 的HTTP请求消息的请求方式也为GET;
c. 使用GET请求方式WEB服务器传递参数的格式:http://localhost:8080/Servlet2/loginServlet? user=at&password=123;
d. 使用GET方式传送的数据量一般限制在1KB以下。
特点: a.没有在URL地址后面附加参数;
b.传送数据量比GET方式传送的数据量大得多。
代码:
<form action="loginServlet" method="post">
user: <input type="text" name="user"/>
password: <input type="password" name="password"/>
GET方式:
特点: a.在URL地址后面附加参数;
b.传送数据量是有限的,一般限制在1KB一下。
代码:
<form action="/loginServlet" method="get">
user: <input type="text" name="user"/>
password: <input type="password" name="password"/>
<input type="submit" value="Submit"/> </form>
a. 在浏览器地址栏中输入某个URL地址或单机网页上的一个超链接时,浏览器发出的HTTP请求消息 的请求方式为GET;
b. 如果网页中的<form>表单元素的method属给性被设置为“get”,浏览器提交这个FORM表单时生成 的HTTP请求消息的请求方式也为GET;
c. 使用GET请求方式WEB服务器传递参数的格式:http://localhost:8080/Servlet2/loginServlet? user=at&password=123;
d. 使用GET方式传送的数据量一般限制在1KB以下。
POST方式:
特点: a.没有在URL地址后面附加参数;
b.传送数据量比GET方式传送的数据量大得多。
代码:
<form action="loginServlet" method="post">
user: <input type="text" name="user"/>
password: <input type="password" name="password"/>
<input type="submit" value="Submit"/></form>
总结:
a. 如果网页中的<form>表单元素的method属给性被设置为“post”,浏览器提交这个FORM表单时生成 的HTTP请求消息的请求方式为“post”;
b. 其他方法全部为“get”方法;
c. 使用post请求方式WEB服务器传递参数的格式:http://localhost:8080/Servlet2/loginServlet ;
d. 传送数据量比GET方式传送的数据量大得多。