<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="http://127.0.0.1:9090" method="post">
<table border="1" bordercolor="#00ffff" cellpadding=10 cellspacing=0 width=500px>
<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="reps"></td>
</tr>
<tr>
<td>选择性别</td>
<td><input type="radio" name="sex" value="male">男
<input type="radio" name="sex" value="female">女
</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="us">--美国--</option>
<option value="en">--英国--</option>
<option value="cn">--中国--</option>
</td>
</tr>
<tr>
<th>
<input type="reset" value="清除数据"/>
<input type="submit" value="提交数据"/>
</th>
<td></td>
</tr>
</form>
</body>
<!--
地址栏:http://127.0.0.1:9090/
提交方式:post
POST / HTTP/1.1
Host: 127.0.0.1:9090
Connection: keep-alive
Content-Length: 52
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8
user=xs&psw=ss&reps=ss&sex=male&tech=java&country=us
get 提交和post 提交的区别
1
get提交 提交的信息都显示在地址栏中
post提交 提交的信息都不显示在地址栏中
2 get提交 对于敏感信息不安全
post提交 对敏感信息安全
3 get提交 对于大数据不行 因为地址栏存储体积有限
post提交 可以提交大体积数据
4
get提交 将信息封装到了请求消息的请求行中
post提交 将信息封装到了请求消息的请求体中
在服务端的一个区别
如果出现将中文提交到tomcat服务器 服务器默认会用iso8859-1进行解码会出现乱码
通过iso8859-1进行编码 再用指定的中文码表解码 即可
这种方式对get post都有效
但是对于post提交的中文 还有另一种解决办法 就是直接使用服务端的一个对象
request对象的setCharacterEncoding方法 直接设定指定的中文码表就可以将中文解析出来
这个方法只对请求体中的数据进行解码
综 所诉 表单那提交 建议使用post
和服务端交互的三种方式
1 地址栏输入url get
2 超链接 get
3 表单 get post
如果在客户端进行增强型的校验 (只要有一个组件的内容是错误的 是无法继续提交的 只有全队才可以提交)
问 服务端接收数据后 还需要校验吗
需要 为了安全性
如果服务端做了增强型的校验 客户端还需要校验吗
需要 为了提高用户的上网体验效果 还有减轻服务器端的压力
地址栏 :http://127.0.0.1:9090/?user=d&psw=s&reps=s&sex=male&tech=java&country=us
提交方式 get提交
GET /?user=d&psw=s&reps=s&sex=male&tech=java&country=us HTTP/1.1
Host: 127.0.0.1:9090
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8-->
</html>
HTML 表单的格式化 post 和get的区别
最新推荐文章于 2023-08-09 11:17:39 发布