get提交和post提交的区别

xiaoxiao2021-02-28  110

1.get提交,提交的信息都显示在地址栏中

  post提交,提交的信息不显示在地址栏中

 

2.get提交,对于敏感的数据信息不安全

  post提交,对于敏感的数据信息安全

 

3.get提交,对于大数据不行,因为地址栏存储的体积有限

  post提交,对于可以提交大数据

 

4.get提交,将信息封装到了请求信息的请求行中

   post提交,将信息封装到了请求信息的请求体中

如下例子所示

<1>创建一个服务器

package com.server; import java.io.InputStream; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; public class Test { public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(6666); Socket s = ss.accept(); InputStream in = s.getInputStream(); byte[] buf = new byte[1024]; int len = in.read(buf); System.out.println(new String(buf, 0, len)); PrintWriter out = new PrintWriter(s.getOutputStream(), true); out.println("<font color='green' size='7'>注册成功!</font>"); s.close(); ss.close(); } }

<2>创建html页面

<!DOCTYPE html> <html> <head> <title>index.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <form action="http://127.0.0.1:6666"> 姓名:<input type="text" name="name"/><br /> 密码:<input type="password" name="psw"/><br /> <input type="submit" value="提交"/> </form> </body> </html>

注意:一定要先运行服务器的程序,然后再运行html页面,填写数据,提交数据

转载请注明原文地址: https://www.6miu.com/read-47595.html

最新回复(0)