zoukankan      html  css  js  c++  java
  • get方式和post方式的区别

        1.请求的URL地址不同:
                post:"http://192.168.13.83:8080/itheima74/servlet/LoginServlet"
                get:http://192.168.13.83:8080/itheima74/servlet/LoginServlet?username=root&pwd=123

            2.请求头不同:
                post方式多了几个请求头:Content-Length   Cache-Control  Origin

                openConnection.setRequestProperty("Content-Length", body.length()+"");
                openConnection.setRequestProperty("Cache-Control", "max-age=0");
                openConnection.setRequestProperty("Origin", "http://192.168.13.83:8080");

                 post方式还多了请求的内容:username=root&pwd=123

                 //设置UrlConnection可以写请求的内容
                openConnection.setDoOutput(true);
                //获取一个outputstream,并将内容写入该流
                openConnection.getOutputStream().write(body.getBytes());

             3.请求时携带的内容大小不同
                get:1k 
                post:理论无限制

  • 相关阅读:
    hdu 1875 Krustal最小生成树
    寒假学习PID和latex随笔2013/2/10
    HDU:今年暑假不AC
    HDU:七夕节
    寒假规划
    HDU:开门人和关门人
    HDU:cake
    HDU:最小公倍数
    HDU:Who's in the Middle
    Latex 第一个程序 效果
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/5807193.html
Copyright © 2011-2022 走看看