What's the difference between org.springframework.http.httpRequest and httpServletRequest?

beginners of Java and spring boot, recently want to be interceptors of resttemplate, and found methods in interceptors

ClientHttpResponse intercept (HttpRequest request, byte [] body, ClientHttpRequestExecution execution)

The

parameter is the request information of the httpRequest, project in actual combat. Generally, the two methods of javax.servlet.http.httpservletRequest
are also different. The HttpServlet object can only be indexed by the header name, and the getheaders of HttpRequest returns the complete HttpHeader object, and the method makes it clear that the return value is not empty.

/**
 * Return the headers of this message.
 * @return a corresponding HttpHeaders object (never {@code null})
 */
HttpHeaders getHeaders();

this is also a bit confusing. What do you get if you build a request,httpRequest with header as null through HttpEntity request = new HttpEntity < > (body, headers);?

what are the connections and differences between the two? I have already googled and failed to find a suitable answer. Thank you

May.06,2021

use HttpServletRequest because you use Servlet
instead of RestTemplate you can only use HttpRequest because RestTemplate is an abstraction made by spring itself, and of course you can only use your own things

.
Menu