zoukankan      html  css  js  c++  java
  • http协议-配置与调用

    Http协议:

                       1)http协议: 对浏览器客户端和服务器端之间数据传输的格式规范。

                       2)http请求:浏览器->服务器端

                                         格式:

                                                   请求行(请求方式(GET/POST) 请求资源(URI) http协议版本(http1.1))

                                                   请求头(键值对形式存在。 host、user-agent、referer)

                                                   一个空行

                                                   实体内容(POST提交的参数)

                                         HttpServletRequest对象: 请求对象。获取请求信息。

                                         请求行:request.getMethod()   request.getRequestURI/getRequestURL()  request.getProtocol();

                                         请求头: request.getHeader("name")    request.getHeaderNames() 

                                         实体内容: request.getInputStream()

                                         获取参数数据:(GET或POST)

                                                            request.getParameter("name")  一个值的参数

                                                            request.getParameterValues("name"); 多个值的参数

                                                            request.getParameterNames()    所有参数

                                                           

                       3)http响应: 服务器->浏览器端

                                         格式:

                                                   响应行(http协议版本 状态码 描述)

                                                            常用的状态码: 200   302  404   500

                                                   响应头( location(结合302状态码完成请求重定向功能)、 refresh(定时刷新)、content-type、content-disiposition(以下载方式打开))

                                                   一个空行

                                                   实体内容

                                         HttpServletResponse对象: 响应对象。设置响应信息。

                                                   响应行: response.setStatus();

                                                   响应头: response.setHeader("name","value")

                                                   实体内容:

                                                                     (PrintWriter) response.getWriter().writer(); 字符内容

                                                              (OutputStream)response.getOutputStream().writer();  字节内容

  • 相关阅读:
    【深度学习Deep Learning】资料大全
    在谷歌中缓存下载视频离线观看,js代码
    asp.net mvc 中Html.ValidationSummary显示html
    asp.net网站访问时不能显示页面
    k8s install kubeadm网络原因访问不了谷哥and gpg: no valid OpenPGP data found. 解决办法
    火绒杀毒软件更安静
    Linux使用mount挂载Windows共享文件夹
    spark学习
    https://blog.csdn.net/tangdong3415/article/details/53432166
    正则表达式
  • 原文地址:https://www.cnblogs.com/chenzxl/p/7906417.html
Copyright © 2011-2022 走看看