zoukankan      html  css  js  c++  java
  • 302 Moved Temporarily

    这个就是表示 重定向!! 不过,302在不同HTTP协议下的状态信息不同。

    302 Moved temporarily (redirect) 你所连接的页面进行了Redirect 
    
    302 Found 类似于301,但新的URL应该被视为临时性的替代,而不是永久性的。注意,在HTTP1.0中对应的状态信息是“Moved Temporatily”,而HttpServletResponse中相应的常量是SC_MOVED_TEMPORARILY,而不是SC_FOUND。出现该状态代码时,浏览器能够自动访问新的URL,因此它是一个很有用的状态代码。为此,Servlet提供了一个专用的方法,即sendRedirect。使用response.sendRedirect(url)比使用response.setStatus(response.SC_MOVED_TEMPORARILY)和response.setHeader("Location",url)更好。这是因为: 
    
    首先,代码更加简洁。 
    第二,使用sendRedirect,Servlet会自动构造一个包含新链接的页面(用于那些不能自动重定向的老式浏览器)。 
    最后,sendRedirect能够处理相对URL,自动把它们转换成绝对URL。 
    注意这个状态代码有时候可以和301替换使用。例如,如果浏览器错误地请求http://host/~user(缺少了后面的斜杠),有的服务器返回301,有的则返回302。 
    严格地说,我们只能假定只有当原来的请求是GET时浏览器才会自动重定向。
    参考资料: http://zhidao.baidu.com/question/16119833.html?si=4

    http://segmentfault.com/q/1010000000094621

    二者在不同HTTP协议下的状态信息不同。
    
    在HTTP/1.0 302 状态为 Moved Temporarily
    
    The requested resource resides temporarily under a different URL. Since the redirection may be altered on occasion, the client should continue to use the Request-URI for future requests.
    在HTTP/1.1 302 状态为 Found
    
    The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.
  • 相关阅读:
    Win7最高权限问题
    UNEDI/FACT基础知识
    关于display
    sql server 复制需要有实际的服务器名称才能连接到服务器
    ANSI ASC X12标准学习指南
    Eclipse插件的安装方法
    PB DataWindow的38个技巧
    Java API 帮助文档中英文版下载
    用快捷方式在Windows2008下安装新字体的技巧
    sqlserver 性能分析报表
  • 原文地址:https://www.cnblogs.com/FlyAway2013/p/4090493.html
Copyright © 2011-2022 走看看