前言:HttpServletRequest对象封装了客户端进行HTTP协议请求时的所有信息,HttpServletRequest继承了ServletRequest,所以和ServletRequest一样,是由tomcat服务器提供实现的。具体过程如下:

1)Web客户向Servlet容器发出Http请求;

2)Servlet容器解析Web客户的Http请求;

3)Servlet容器创建一个HttpRequest对象,在这个对象中封装Http请求信息;



1.HttpServlet

说到HttpServletRequest就不得不说一下HttpServlet,下面看它的API:

javax.servlet.http

Class HttpServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
All Implemented Interfaces:
Serializable,Servlet,ServletConfig
Method Summary
protected  void doDelete(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a DELETE request.
protected  void doGet(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a GET request.
protected  void doHead(HttpServletRequest req,HttpServletResponse resp)

          Receives an HTTP HEAD request from the protected service method and handles the request.
protected  void doOptions(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a OPTIONS request.
protected  void doPost(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a POST request.
protected  void doPut(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a PUT request.
protected  void doTrace(HttpServletRequest req,HttpServletResponse resp)

          Called by the server (via the service method) to allow a servlet to handle a TRACE request.
protected  long getLastModified(HttpServletRequest req)

          Returns the time the HttpServletRequest object was last modified, in milliseconds since midnight January 1, 1970 GMT.
protected  void service(HttpServletRequest req,HttpServletResponse resp)

          Receives standard HTTP requests from the public service method and dispatches them to thedoXXX methods defined in this class.
 void service(ServletRequest req,ServletResponse res)

          Dispatches client requests to the protected service method.

可以看到HttpServlet实现了servlet接口,所以其中的service(ServletRequest req,ServletResponse res)方法和servlet中的一致,在每次请求时调用。只抽取部分方法,概要信息如下:

(1).doGet(HttpServletRequest req,HttpServletResponse resp):接收HTTP的GET请求;

(2).doPost(HttpServletRequest req,HttpServletResponse resp):接收HTTP的POST请求;

(3).service(HttpServletRequest req,HttpServletResponse resp):接收HTTP请求,并把它分配到doXXX方法中;





2.HttpServletRequest的API:

javax.servlet.http

Interface HttpServletRequest

All Superinterfaces:
ServletRequest
All Known Implementing Classes:
HttpServletRequestWrapper
 String getAuthType()

          Returns the name of the authentication scheme used to protect the servlet.
 String getContextPath()

          Returns the portion of the request URI that indicates the context of the request.
 Cookie[] getCookies()

          Returns an array containing all of the Cookie objects the client sent with this request.
 long getDateHeader(String name)

          Returns the value of the specified request header as a long value that represents aDate object.
 String getHeader(String name)

          Returns the value of the specified request header as a String.
 Enumeration getHeaderNames()

          Returns an enumeration of all the header names this request contains.
 Enumeration getHeaders(String name)

          Returns all the values of the specified request header as an Enumeration ofString objects.
 int getIntHeader(String name)

          Returns the value of the specified request header as an int.
 String getMethod()

          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 String getPathInfo()

          Returns any extra path information associated with the URL the client sent when it made this request.
 String getPathTranslated()

          Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
 String getQueryString()

          Returns the query string that is contained in the request URL after the path.
 String getRemoteUser()

          Returns the login of the user making this request, if the user has been authenticated, ornull if the user has not been authenticated.
 String getRequestedSessionId()

          Returns the session ID specified by the client.
 String getRequestURI()

          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 StringBuffer getRequestURL()

          Reconstructs the URL the client used to make the request.
 String getServletPath()

          Returns the part of this request's URL that calls the servlet.
 HttpSession getSession()

          Returns the current session associated with this request, or if the request does not have a session, creates one.
 HttpSession getSession(boolean create)

          Returns the current HttpSession associated with this request or, if there is no current session andcreate is true, returns a new session.
 Principal getUserPrincipal()

          Returns a java.security.Principal object containing the name of the current authenticated user.
 boolean isRequestedSessionIdFromCookie()

          Checks whether the requested session ID came in as a cookie.
 boolean isRequestedSessionIdFromUrl()

          Deprecated. As of Version 2.1 of the Java Servlet API, useisRequestedSessionIdFromURL()
instead.
 boolean isRequestedSessionIdFromURL()

          Checks whether the requested session ID came in as part of the request URL.
 boolean isRequestedSessionIdValid()

          Checks whether the requested session ID is still valid.
 boolean isUserInRole(String role)

          Returns a boolean indicating whether the authenticated user is included in the specified logical "role".

这里只列举常用的几个方法(有些API中没有列举到的,是在ServletRequest中已有的方法):

(1)获得客户机信息                                                                       



getRequestURL():返回客户端发出请求时的完整URL。

getRequestURI():返回请求行中的资源名部分。

getQueryString() :返回请求行中的参数部分。

getRemoteAddr():返回发出请求的客户机的IP地址。

getRemoteHost() :返回发出请求的客户机的完整主机名。

getRemotePort():返回客户机所使用的网络端口号。

getLocalAddr() :返回WEB服务器的IP地址。

getLocalName():返回WEB服务器的主机名。

(2)获得客户机请求头                                                                    



getHeaders(String name):获得请求头信息组成的Enumeration。



(3)获得客户机请求参数(客户端提交的数据)                                            



getParameterMap():获取参数名和参数值的String[]组成的键值对,即返回的类型为Map(String,String[]),用于多参数值。





3.项目的目录结构

4.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>javaWeb_07</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>httpRequestDemo</servlet-name>
<servlet-class>com.dao.chu.HttpRequestDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>httpRequestDemo</servlet-name>
<url-pattern>/httpRequest</url-pattern>
</servlet-mapping>
</web-app>

5.login.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>登陆页</title>
</head>
<body> <!-- 相对路径写action="httpRequest"; -->
<!-- 绝对路径写action="/javaWeb_07/httpRequest"; --> <form action="httpRequest" method="get">
用户名:<input type="text" name="user">
<br><br>
密码  <input type="password" name="password">
<br><br> <!-- 一组信息 -->
interesting:
<input type="checkbox" name="interesting" value="reading">Reading
<input type="checkbox" name="interesting" value="writing">Writing
<input type="checkbox" name="interesting" value="football">Football
<input type="checkbox" name="interesting" value="game">Game
<input type="checkbox" name="interesting" value="shopping">Shopping
<input type="checkbox" name="interesting" value="party">Party
<input type="checkbox" name="interesting" value="TV">TV <br><br> <input type="submit" value="提交">
</form> </body>
</html>

6.HttpRequestDemo.java,分三种情况,对应后面的三种现象

(1)只写一个service方法

package com.dao.chu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
*
* <p>
* Title: HttpRequestDemo Description:继承了HttpServlet的测试类
* </p>
*/
public class HttpRequestDemo extends HttpServlet { /** serialVersionUID */
private static final long serialVersionUID = 1L; // 得到请求的URL地址
String requestUrl = "";
// 得到请求行中的资源部分
String requestUri = "";
// 得到请求的URL地址中附带的参数
String queryString = "";
// 得到来访者的IP地址
String remoteAddr = "";
// 来访者主机名
String remoteHost = "";
// 客户机所使用的网络端口号
int remotePort = 0;
// 得到请求方式GET/POST
String method = "";
// 获取WEB服务器的IP地址
String localAddr = "";
// 获取WEB服务器的主机名
String localName = ""; /**
* 继承了HttpServlet的service方法
*/
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { //调用公共输出方法
commonPrint(request, response); } /**
* Title: commonPrint
* Description:公共输出方法
* @param request
* @param response
*/
private void commonPrint(HttpServletRequest request,
HttpServletResponse response) { // 设置将字符以"UTF-8"编码输出到客户端浏览器
response.setCharacterEncoding("UTF-8");
// 通过设置响应头控制浏览器以UTF-8的编码显示数据,如果不加这句话,那么浏览器显示的将是乱码
response.setHeader("content-type", "text/html;charset=UTF-8"); requestUrl = request.getRequestURL().toString();
requestUri = request.getRequestURI();
queryString = request.getQueryString();
remoteAddr = request.getRemoteAddr();
method = request.getMethod();
localAddr = request.getLocalAddr();
localName = request.getLocalName(); PrintWriter out;
try {
out = response.getWriter(); out.write("<hr/>");
out.write("(1)获取客户机信息:");
out.write("<br/>");
out.write("请求的URL地址:" + requestUrl);
out.write("<br/>");
out.write("请求的资源:" + requestUri);
out.write("<br/>");
out.write("请求的URL地址中附带的参数:" + queryString);
out.write("<br/>");
out.write("来访者的IP地址:" + remoteAddr);
out.write("<br/>");
out.write("来访者的主机名:" + remoteHost);
out.write("<br/>");
out.write("使用的端口号:" + remotePort);
out.write("<br/>");
out.write("请求的方式:" + method);
out.write("<br/>");
out.write("服务器的IP地址:" + localAddr);
out.write("<br/>");
out.write("服务器的主机名:" + localName); // 获取的客户机的请求头信息
out.write("<br/>");
out.write("<hr/>");
out.write("(2)获取客户机的请求头信息:");
out.write("<br/>"); // 得到所有请求头名组成的Enumeration
Enumeration<String> headerNames = request.getHeaderNames(); // 循环
while (headerNames.hasMoreElements()) { // 得到所有的请求头名
String headerName = (String) headerNames.nextElement();
// 根据请求头名得到所有请求头值
String headerValue = request.getParameter(headerName);
out.write(headerName + ": " + headerValue);
out.write("<br/>");
} // 获取的客户机的请求信息
out.write("<br/>");
out.write("<hr/>");
out.write("(3)获取客户机的请求信息:");
out.write("<br/>"); // 获取参数名和参数值的String[]组成的键值对
Map<String, String[]> map = request.getParameterMap();
Set<Entry<String, String[]>> entrySet = map.entrySet();
for (Entry<String, String[]> entry : entrySet) { out.write(entry.getKey() + ": "
+ Arrays.asList(entry.getValue()));
out.write("<br/>");
} } catch (IOException e) {
e.printStackTrace();
} } }

(2)写有service方法,doget方法,dopost方法

package com.dao.chu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
*
* <p>
* Title: HttpRequestDemo Description:继承了HttpServlet的测试类
* </p>
*/
public class HttpRequestDemo extends HttpServlet { /** serialVersionUID */
private static final long serialVersionUID = 1L; // 得到请求的URL地址
String requestUrl = "";
// 得到请求行中的资源部分
String requestUri = "";
// 得到请求的URL地址中附带的参数
String queryString = "";
// 得到来访者的IP地址
String remoteAddr = "";
// 来访者主机名
String remoteHost = "";
// 客户机所使用的网络端口号
int remotePort = 0;
// 得到请求方式GET/POST
String method = "";
// 获取WEB服务器的IP地址
String localAddr = "";
// 获取WEB服务器的主机名
String localName = ""; /**
* 继承了HttpServlet的service方法
*/
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { System.out.println("调用了service方法");
//调用公共输出方法
commonPrint(request, response); } /**
* 继承了HttpServlet的doGet方法
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { System.out.println("调用了doGet方法");
//调用公共输出方法
commonPrint(request, response);
} /**
* 继承了HttpServlet的doPost方法
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { System.out.println("调用了doPost方法");
//调用公共输出方法
commonPrint(request, response);
} /**
* Title: commonPrint
* Description:公共输出方法
* @param request
* @param response
*/
private void commonPrint(HttpServletRequest request,
HttpServletResponse response) { // 设置将字符以"UTF-8"编码输出到客户端浏览器
response.setCharacterEncoding("UTF-8");
// 通过设置响应头控制浏览器以UTF-8的编码显示数据,如果不加这句话,那么浏览器显示的将是乱码
response.setHeader("content-type", "text/html;charset=UTF-8"); requestUrl = request.getRequestURL().toString();
requestUri = request.getRequestURI();
queryString = request.getQueryString();
remoteAddr = request.getRemoteAddr();
method = request.getMethod();
localAddr = request.getLocalAddr();
localName = request.getLocalName(); PrintWriter out;
try {
out = response.getWriter(); out.write("<hr/>");
out.write("(1)获取客户机信息:");
out.write("<br/>");
out.write("请求的URL地址:" + requestUrl);
out.write("<br/>");
out.write("请求的资源:" + requestUri);
out.write("<br/>");
out.write("请求的URL地址中附带的参数:" + queryString);
out.write("<br/>");
out.write("来访者的IP地址:" + remoteAddr);
out.write("<br/>");
out.write("来访者的主机名:" + remoteHost);
out.write("<br/>");
out.write("使用的端口号:" + remotePort);
out.write("<br/>");
out.write("请求的方式:" + method);
out.write("<br/>");
out.write("服务器的IP地址:" + localAddr);
out.write("<br/>");
out.write("服务器的主机名:" + localName); // 获取的客户机的请求头信息
out.write("<br/>");
out.write("<hr/>");
out.write("(2)获取客户机的请求头信息:");
out.write("<br/>"); // 得到所有请求头名组成的Enumeration
Enumeration<String> headerNames = request.getHeaderNames(); // 循环
while (headerNames.hasMoreElements()) { // 得到所有的请求头名
String headerName = (String) headerNames.nextElement();
// 根据请求头名得到所有请求头值
String headerValue = request.getParameter(headerName);
out.write(headerName + ": " + headerValue);
out.write("<br/>");
} // 获取的客户机的请求信息
out.write("<br/>");
out.write("<hr/>");
out.write("(3)获取客户机的请求信息:");
out.write("<br/>"); // 获取参数名和参数值的String[]组成的键值对
Map<String, String[]> map = request.getParameterMap();
Set<Entry<String, String[]>> entrySet = map.entrySet();
for (Entry<String, String[]> entry : entrySet) { out.write(entry.getKey() + ": "
+ Arrays.asList(entry.getValue()));
out.write("<br/>");
} } catch (IOException e) {
e.printStackTrace();
} } }

(3)写有service方法,doget方法,dopost方法,且service方法调用了父类的service(HttpServletRequest req,HttpServletResponse resp)方法。

package com.dao.chu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; /**
*
* <p>
* Title: HttpRequestDemo Description:继承了HttpServlet的测试类
* </p>
*/
public class HttpRequestDemo extends HttpServlet { /** serialVersionUID */
private static final long serialVersionUID = 1L; // 得到请求的URL地址
String requestUrl = "";
// 得到请求行中的资源部分
String requestUri = "";
// 得到请求的URL地址中附带的参数
String queryString = "";
// 得到来访者的IP地址
String remoteAddr = "";
// 来访者主机名
String remoteHost = "";
// 客户机所使用的网络端口号
int remotePort = 0;
// 得到请求方式GET/POST
String method = "";
// 获取WEB服务器的IP地址
String localAddr = "";
// 获取WEB服务器的主机名
String localName = ""; /**
* 继承了HttpServlet的service方法
*/
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { System.out.println("调用了service方法");
//调用公共输出方法
commonPrint(request, response); //依旧调用父类的方法
super.service(request, response); } /**
* 继承了HttpServlet的doGet方法
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { System.out.println("调用了doGet方法");
//调用公共输出方法
commonPrint(request, response);
} /**
* 继承了HttpServlet的doPost方法
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { System.out.println("调用了doPost方法");
//调用公共输出方法
commonPrint(request, response);
} /**
* Title: commonPrint
* Description:公共输出方法
* @param request
* @param response
*/
private void commonPrint(HttpServletRequest request,
HttpServletResponse response) { // 设置将字符以"UTF-8"编码输出到客户端浏览器
response.setCharacterEncoding("UTF-8");
// 通过设置响应头控制浏览器以UTF-8的编码显示数据,如果不加这句话,那么浏览器显示的将是乱码
response.setHeader("content-type", "text/html;charset=UTF-8"); requestUrl = request.getRequestURL().toString();
requestUri = request.getRequestURI();
queryString = request.getQueryString();
remoteAddr = request.getRemoteAddr();
method = request.getMethod();
localAddr = request.getLocalAddr();
localName = request.getLocalName(); PrintWriter out;
try {
out = response.getWriter(); out.write("<hr/>");
out.write("(1)获取客户机信息:");
out.write("<br/>");
out.write("请求的URL地址:" + requestUrl);
out.write("<br/>");
out.write("请求的资源:" + requestUri);
out.write("<br/>");
out.write("请求的URL地址中附带的参数:" + queryString);
out.write("<br/>");
out.write("来访者的IP地址:" + remoteAddr);
out.write("<br/>");
out.write("来访者的主机名:" + remoteHost);
out.write("<br/>");
out.write("使用的端口号:" + remotePort);
out.write("<br/>");
out.write("请求的方式:" + method);
out.write("<br/>");
out.write("服务器的IP地址:" + localAddr);
out.write("<br/>");
out.write("服务器的主机名:" + localName); // 获取的客户机的请求头信息
out.write("<br/>");
out.write("<hr/>");
out.write("(2)获取客户机的请求头信息:");
out.write("<br/>"); // 得到所有请求头名组成的Enumeration
Enumeration<String> headerNames = request.getHeaderNames(); // 循环
while (headerNames.hasMoreElements()) { // 得到所有的请求头名
String headerName = (String) headerNames.nextElement();
// 根据请求头名得到所有请求头值
String headerValue = request.getParameter(headerName);
out.write(headerName + ": " + headerValue);
out.write("<br/>");
} // 获取的客户机的请求信息
out.write("<br/>");
out.write("<hr/>");
out.write("(3)获取客户机的请求信息:");
out.write("<br/>"); // 获取参数名和参数值的String[]组成的键值对
Map<String, String[]> map = request.getParameterMap();
Set<Entry<String, String[]>> entrySet = map.entrySet();
for (Entry<String, String[]> entry : entrySet) { out.write(entry.getKey() + ": "
+ Arrays.asList(entry.getValue()));
out.write("<br/>");
} } catch (IOException e) {
e.printStackTrace();
} } }

7.填写jsp页面表单,发出HTTP请求

8.三种情况的现象

(1)页面显示

控制台无输出,说明成功调用了service方法。

(2)页面显示

控制台输出:

说明虽然写了dopost和doget方法,但是却没有接收到请求。

(3)页面显示

控制台打印:

很显然这次接收到了doGET方法

8.为了追求根源,我们找到HttpServlet的service方法的源码:

/**
* <p>Title: HttpServlet的service方法的源码</p>
* <p>Description: </p>
* @throws ServletException
* @throws IOException
*/
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String method = req.getMethod();
if (method.equals("GET")) {
long lastModified = getLastModified(req);
if (lastModified == -1L) { doGet(req, resp);
} else {
long ifModifiedSince;
try {
ifModifiedSince = req.getDateHeader("If-Modified-Since");
} catch (IllegalArgumentException iae) {
ifModifiedSince = -1L;
}
if (ifModifiedSince < lastModified / 1000L * 1000L) { maybeSetLastModified(resp, lastModified);
doGet(req, resp);
} else {
resp.setStatus(304);
}
}
} else if (method.equals("HEAD")) {
long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
doHead(req, resp);
} else if (method.equals("POST")) {
doPost(req, resp);
} else if (method.equals("PUT")) {
doPut(req, resp);
} else if (method.equals("DELETE")) {
doDelete(req, resp);
} else if (method.equals("OPTIONS")) {
doOptions(req, resp);
} else if (method.equals("TRACE")) {
doTrace(req, resp); } else { String errMsg = lStrings.getString("http.method_not_implemented");
Object[] errArgs = new Object[1];
errArgs[0] = method;
errMsg = MessageFormat.format(errMsg, errArgs); resp.sendError(501, errMsg);
}
}

我们可以看到

String method = req.getMethod();if (method.equals("GET")){doGet(req, resp);}等

的确有接收请求的方式,根据判断的请求方式转到相应的方法。而我们在(2)中继承了HttpServlet,覆盖了service方法,没有调用原来父类的方法,所以即使写了doget和dopost也接收不到请求。

附:

本次项目源码:点击打开链接

javaWEB总结(7):HttpServlet和HttpServletRequest的更多相关文章

  1. javaWEB中的HttpServlet(企业开发使用)

    HttpServlet: 1). 是一个 Servlet, 继承自 GenericServlet. 针对于 HTTP 协议所定制. 2). 在 service() 方法中直接把 ServletReuq ...

  2. javaWEB总结(10):HttpServlet成长史

    前言: 从Servlet,ServletConfig到GenericServlet再到Httpservlet的整个过程,相当于Httpservlet的成长史,我们不需要写那么臃肿的代码,开发难度由复杂 ...

  3. JAVAWEB开发之HttpServletResponse和HttpServletRequest详解(下)(各种乱码、验证码、重定向和转发)

    HttpServletRequest获取请求头信息  (1)获取客户机请求头 String getHeader(String name) Enumeration<String> getHe ...

  4. [原创]java WEB学习笔记11:HttpServlet(HttpServletRequest HttpServletRsponse) 以及关于 Servlet 小结

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  5. JAVAWEB开发之HttpServletResponse和HttpServletRequest详解(上)(各种乱码、验证码、重定向和转发)

    HttpServletResponse简介 Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象.和代表响应的response对象 request和re ...

  6. [转]【HttpServlet】HttpServletRequest接口

    建立时间:2019.6.28 &6.29 1.HttpServletRequest概述 我们在创建Servlet时会覆盖service()方法,或doGet()/doPost(),这些方法都有 ...

  7. Javaweb学习笔记——上传下载文件

    一.前言 在Javaweb中,上传下载是经常用到的功能,对于文件上传,浏览器在上传的过程中是以流的过程将文件传给服务器,一般都是使用commons-fileupload这个包实现上传功能,因为comm ...

  8. JavaWeb结合七牛云存储搭建个人相册服务

    JavaWeb结合七牛云存储搭建个人相册服务 一.引言1. 课程概述 相信很多人都知道网站一般会有很多图片,对于小型网站来说,图片放在网站服务器上不算什么,但当图片数量很大时,会造成服务器很臃肿,相应 ...

  9. log4j在javaWeb项目中的使用

    在前边的文章中对log4j的配置文件进行了说明,今天介绍如何在普通的javaWeb项目中使用log4j. 在日常的开发过程中,日志使用的很频繁,我们可以利用日志来跟踪程序的错误,程序运行时的输出参数等 ...

随机推荐

  1. CentOS7 citus9.5 集群安装及管理

    1 所有节点配置 #------服务安装 服务yum update -y #------扩展依赖安装yum install -y epel-release && yum update ...

  2. Spring.net 学习IOC------通过构造器注入

    别的不多说,咱们先上代码 1> object.xml 的文件内容 <?xml version="1.0" encoding="utf-8" ?> ...

  3. jquery学习笔记3——jq HTML

    jQuery最常用的部分就是操作DOM,jQuery提供了一系列操作DOM的相关方法,使其很容易: 一.获取 1.获取内容 text()方法    设置或返回所选元素的文本内容: html()方法   ...

  4. vsphere安装虚拟机

    新建虚拟机完成后,启动虚拟机,打开启动虚拟机控制台,选择CD/DVD驱动器 选择iso镜像,可以是本地或存储中心的iso,选择后点击虚拟机--客户机--发送Ctrl+Alt+Del,接下来就是正常的操 ...

  5. php 5.5 xhprof for windows

    今天看到一个好的性能优软件xhprof(有facebook开发的类库)在国内找了很多网站都没有找到相关php5.5的扩展,只好FQ还是外面的世界精彩一下就找到了link (http://windows ...

  6. MVC修改文件上传大小问题

    在web.config文件的system.web节点的httpRuntime节点加入 maxRequestLength="2147483647" executionTimeout= ...

  7. 永洪BI配置测试及遇到的一些问题

    1.连oracle 11g数据库遇到密码不能验证通过. 在11g中, 数据库默认密码的大小写是敏感的,jdbc在给oracle密码时, 会将其变成大写.其他个别情况也会出现变成小写的. 为统一,去除o ...

  8. 移动app的一些心得

    周末的时候闲着没事,看到了个开源的红旅动漫的APP,于是自己就拿下来写了下,整个网站作者也解析成了接口,所以就可以写成app了,作者写的是用mui开发的,可以通过hbuilder软件打开,进行查看源代 ...

  9. linux卸载rpm包

    先查找要卸载的rpm包:比如cpp: #rpm -qa | grep cpp #rpm -e cpp-2.333x.x 如果提示有依赖,执行: #rpm -e cpp-2222 --nodeps

  10. Tomcat 配置支持APR

    对ARP支持,需要安装以下库: APR library JNI wrappers for APR used by Tomcat (libtcnative) OpenSSL libraries 其中JN ...