Servlet 之 读取读取 HTTP 头

下面的方法可用在 Servlet 程序中读取 HTTP 头。这些方法通过 HttpServletRequest 对象可用:
 
1)Cookie[] getCookies()
返回一个数组,包含客户端发送该请求的所有的 Cookie 对象。
 
2)Object getAttribute(String name)
以对象形式返回已命名属性的值,如果没有给定名称的属性存在,则返回 null。
 
3)String getHeader(String name)
以字符串形式返回指定的请求头的值。Cookie也是头的一种;
 
4)String getParameter(String name)
以字符串形式返回请求参数的值,或者如果参数不存在则返回 null
posted @ 2020-09-06 17:29  随园  阅读(141)  评论(0编辑  收藏  举报