您的位置:首页 > 编程语言 > Java开发

javaseday32(画中画 表单 post get 提交方式)

2017-08-28 16:41 489 查看
<iframe src="html_01.html" height="400" width="600">这是画中画标签 如果看到了你的浏览器不支持此标签</iframe> width height 加.js 可以做恶意弹窗 还看不到


<!--<iframe src="html_01.html" height="400" width="600">这是画中画标签 如果看到了你的浏览器不支持此标签</iframe> width height 加.js 可以做恶意弹窗 还看不到-->
<!--    如果要给服务端提交数据 表单中的组件必须有name和value 属性
用于给服务端获取数据方便
-->
<form>
名字<input type="text" /><br/>
密码<input type="password"  /><br/> name 是键 value是值
性别<input type="radio" name="sex" value="nan"/>男
<input type="radio" name="sex" value="nv" checked="checked" />女<br/>默认选择
选择技术<input type="checkbox"  />JAVA
<input type="checkbox"  />html
<input type="checkbox"  />css
<input type="checkbox"  />oo <br/>
<input type="reset"  value="清除数据"  /> <input type="submit" value="提交数据"/>          选择文件 <input type="file" name="file" />
一个图片<input type="image" src="1.jpg" />通过点击图片提交 提交按钮好看
<!--数据不需要客户端知道 但是可以提交到服务器端让服务器知道 -->
隐藏组件 <input type="hidden" name="myke" value="11" />
一个按钮<input type="button" value="有个按钮" onclick="alert('按钮')"  /><br />
<select>
<option name="country" >选择国家 </option>
<option value="usa"> 美国</option>
<option value="cn" selected="selected">中国</option>
<option value="en">英国</option>
</select>
<textarea name="textarea">text </textarea>
</form>


<!-- get提交
地址栏http://127.0.0.1:9999/?user=gfg&psw=gf&sex=nan&tech=java&country=cn

GET /?user=gh&psw=ds&sex=nan&tech=java&country=cn HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Accept-Encoding: gzip, deflate
Host: 127.0.0.1:9999
DNT: 1
Connection: Keep-Alive
-->
<!-- post
地址栏http://127.0.0.1:9999/

POST / HTTP/1.1
Host: 127.0.0.1:9999
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 42
Connection: keep-alive
Upgrade-Insecure-Requests: 1

user=gfg&psw=gf&sex=nv&tech=web&country=cn
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:9999/?user=xixi&psw=12&repsw=111&tech=java 
-->
<form action="http://127.0.0.1:9999" method="post">
<table border="1" bordercolor="#FFFF00" cellpading="10" cellspacing="0" width="70%">
<tr>
<th colspan="2">注册表单</th><!--单元格才有行列大小 行本身没有 -->
<td></td>
</tr>
<tr>
<th>用户名称</th>
<td><input type="text" name="user" </td>
</tr>

<tr>
<th>输入密码</th>
<td><input type="password" name="psw"</td>
</tr>

<tr>
<th>选择性别</th>
<td><input type="radio" name="sex" value="nan" />男
<input type="radio" name="sex" value="nv" />女</td>
</tr>
<tr>
<th>选择技术</th>
<td><input type="checkbox" name="tech" value="java" />java
<input type="checkbox" name="tech" value="web" />web
<input type="checkbox" name="tech" value="js" />js
</td>
</tr>
<tr>
<th>选择国家</th>
<td>
<select name="country" >
<option value="cn">中国</opti
bb63
on>
<option value="en">英国</option>
<option value="usa">美国</option>
</select>
</td>
</tr>
<tr >
<th colspan="2"><input  type="submit" />
<input type="reset" /></th>
<td></td>
</tr>
<tr>
<th></th>
<td></td>
</tr>

</table>
</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: