接口 HttpRequestHandler
- 所有已知实现类:
BurlapServiceExporter
,DefaultServletHttpRequestHandler
,HessianServiceExporter
,HttpInvokerServiceExporter
,ResourceHttpRequestHandler
,SockJsHttpRequestHandler
,WebSocketHttpRequestHandler
public interface HttpRequestHandler
Plain handler interface for components that process HTTP requests, analogous to a Servlet. Only declaresServletException
andIOException
, to allow for usage within anyHttpServlet
. This interface is essentially the direct equivalent of an HttpServlet, reduced to a central handle method.The easiest way to expose an HttpRequestHandler bean in Spring style is to define it in Spring's root web application context and define an
HttpRequestHandlerServlet
inweb.xml
, pointing to the target HttpRequestHandler bean through itsservlet-name
which needs to match the target bean name.Supported as a handler type within Spring's
DispatcherServlet
, being able to interact with the dispatcher's advanced mapping and interception facilities. This is the recommended way of exposing an HttpRequestHandler, while keeping the handler implementations free of direct dependencies on a DispatcherServlet environment.Typically implemented to generate binary responses directly, with no separate view resource involved. This differentiates it from a
Controller
within Spring's Web MVC framework. The lack of aModelAndView
return value gives a clearer signature to callers other than the DispatcherServlet, indicating that there will never be a view to render.As of Spring 2.0, Spring's HTTP-based remote exporters, such as
HttpInvokerServiceExporter
andHessianServiceExporter
, implement this interface rather than the more extensive Controller interface, for minimal dependencies on Spring-specific web infrastructure.Note that HttpRequestHandlers may optionally implement the
LastModified
interface, just like Controllers can, provided that they run within Spring's DispatcherServlet. However, this is usually not necessary, since HttpRequestHandlers typically only support POST requests to begin with. Alternatively, a handler may implement the "If-Modified-Since" HTTP header processing manually within itshandle
method.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller
- 另请参阅:
HttpRequestHandlerServlet
,DispatcherServlet
,ModelAndView
,Controller
,LastModified
,HttpRequestHandlerAdapter
,HttpInvokerServiceExporter
,HessianServiceExporter
,BurlapServiceExporter
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the given request, generating a response.
方法详细资料
handleRequest
void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
Process the given request, generating a response.- 参数:
request
- current HTTP requestresponse
- current HTTP response- 抛出:
ServletException
- in case of general errorsIOException
- in case of I/O errors