1、介绍
用于表单提交,定义表单整体属性,以及容纳其他表单标签。
2、action属性
表示表单提交的地址,可以是绝对地址,也可以是相对地址。如果不设置,默认是当前地址栏url。
3、method属性
表示表单提交时的方法,可选是get/post,默认是get。
如果是post,则表单数据在请求体部。如果是get,则表单数据在url中。
4、enctype属性
表示提交数据时的数据格式。
可选值:
| application/x-www-form-urlencoded | 默认。在发送前对所有字符进行编码(将空格转换为 “+” 符号,特殊字符转换为 ASCII HEX 值)。 |
| multipart/form-data | 不对字符编码。当使用有文件上传控件的表单时,该值是必需的。 |
| text/plain | 将空格转换为 “+” 符号,但不编码特殊字符。 |
5、autocomplate属性
选择是否自动填写表单,可选值on/off,默认值为on,浏览器会根据保存的信息以及表单元素的name属性填写表单。
而该属性的关闭,某些浏览器并不支持。
6、name属性
用于对表单进行操作
7、target属性
规定在何处打开新的页面。
_blank:新标签页
_self:当前标签页
_parent:父框架
_top:顶层框架,即导航栏
8、请求报文分析
html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form action="http://120.48.75.111/a.php?name=张三'<>" method="post">
<input type="text" name="abz">
<input type=submit value=提交>
</form>
</body>
</html>
请求报文:
POST /a.php?name=%E5%BC%A0%E4%B8%89%27%3C%3E HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Content-Length: 28
Content-Type: application/x-www-form-urlencoded
Host: 120.48.75.111
Origin: http://120.48.75.111
Proxy-Connection: keep-alive
Referer: http://120.48.75.111/wordpress/abc.html
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5249.62 Safari/537.36
abz=abx%E4%B8%AD%3C%3E%27%22
分析:
- 默认接收所有响应
- 默认具有referer和origin字段
- 默认的Content-Type: application/x-www-form-urlencoded,且会对请求体部编码