类 SimpleServletHandlerAdapter
- java.lang.Object
- org.springframework.web.servlet.handler.SimpleServletHandlerAdapter
- 所有已实现的接口:
HandlerAdapter
public class SimpleServletHandlerAdapter extends Object implements HandlerAdapter
Adapter to use the Servlet interface with the generic DispatcherServlet. Calls the Servlet'sservice
method to handle a request.Last-modified checking is not explicitly supported: This is typically handled by the Servlet implementation itself (usually deriving from the HttpServlet base class).
This adapter is not activated by default; it needs to be defined as a bean in the DispatcherServlet context. It will automatically apply to mapped handler beans that implement the Servlet interface then.
Note that Servlet instances defined as bean will not receive initialization and destruction callbacks, unless a special post-processor such as SimpleServletPostProcessor is defined in the DispatcherServlet context.
Alternatively, consider wrapping a Servlet with Spring's ServletWrappingController. This is particularly appropriate for existing Servlet classes, allowing to specify Servlet initialization parameters etc.
- 从以下版本开始:
- 1.1.5
- 作者:
- Juergen Hoeller
- 另请参阅:
Servlet
,HttpServlet
,SimpleServletPostProcessor
,ServletWrappingController
构造器概要
构造器 构造器 说明 SimpleServletHandlerAdapter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 long
getLastModified(HttpServletRequest request, Object handler)
Same contract as for HttpServlet'sgetLastModified
method.ModelAndView
handle(HttpServletRequest request, HttpServletResponse response, Object handler)
Use the given handler to handle this request.boolean
supports(Object handler)
Given a handler instance, return whether or not thisHandlerAdapter
can support it.
构造器详细资料
SimpleServletHandlerAdapter
public SimpleServletHandlerAdapter()
方法详细资料
supports
public boolean supports(Object handler)
从接口复制的说明:HandlerAdapter
Given a handler instance, return whether or not thisHandlerAdapter
can support it. Typical HandlerAdapters will base the decision on the handler type. HandlerAdapters will usually only support one handler type each.A typical implementation:
return (handler instanceof MyHandler);
- 指定者:
supports
在接口中HandlerAdapter
- 参数:
handler
- handler object to check- 返回:
- whether or not this object can use the given handler
handle
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
从接口复制的说明:HandlerAdapter
Use the given handler to handle this request. The workflow that is required may vary widely.- 指定者:
handle
在接口中HandlerAdapter
- 参数:
request
- current HTTP requestresponse
- current HTTP responsehandler
- handler to use. This object must have previously been passed to thesupports
method of this interface, which must have returnedtrue
.- 返回:
- ModelAndView object with the name of the view and the required model data, or
null
if the request has been handled directly - 抛出:
Exception
- in case of errors
getLastModified
public long getLastModified(HttpServletRequest request, Object handler)
从接口复制的说明:HandlerAdapter
Same contract as for HttpServlet'sgetLastModified
method. Can simply return -1 if there's no support in the handler class.- 指定者:
getLastModified
在接口中HandlerAdapter
- 参数:
request
- current HTTP requesthandler
- handler to use- 返回:
- the lastModified value for the given handler
- 另请参阅:
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest)
,LastModified.getLastModified(javax.servlet.http.HttpServletRequest)