Class RequestMappingHandlerAdapter

    • Constructor Detail

      • RequestMappingHandlerAdapter

        public RequestMappingHandlerAdapter()
    • Method Detail

      • setArgumentResolvers

        public void setArgumentResolvers(@Nullable
                                         java.util.List<HandlerMethodArgumentResolver> argumentResolvers)
        Configure the complete list of supported argument types thus overriding the resolvers that would otherwise be configured by default.
      • setInitBinderArgumentResolvers

        public void setInitBinderArgumentResolvers(@Nullable
                                                   java.util.List<HandlerMethodArgumentResolver> argumentResolvers)
        Configure the supported argument types in @InitBinder methods.
      • setReturnValueHandlers

        public void setReturnValueHandlers(@Nullable
                                           java.util.List<HandlerMethodReturnValueHandler> returnValueHandlers)
        Configure the complete list of supported return value types thus overriding handlers that would otherwise be configured by default.
      • setMessageConverters

        public void setMessageConverters(java.util.List<HttpMessageConverter<?>> messageConverters)
        Provide the converters to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response.
      • getMessageConverters

        public java.util.List<HttpMessageConverter<?>> getMessageConverters()
        Return the configured message body converters.
      • setRequestBodyAdvice

        public void setRequestBodyAdvice(@Nullable
                                         java.util.List<RequestBodyAdvice> requestBodyAdvice)
        Add one or more RequestBodyAdvice instances to intercept the request before it is read and converted for @RequestBody and HttpEntity method arguments.
      • setResponseBodyAdvice

        public void setResponseBodyAdvice(@Nullable
                                          java.util.List<ResponseBodyAdvice<?>> responseBodyAdvice)
        Add one or more ResponseBodyAdvice instances to intercept the response before @ResponseBody or ResponseEntity return values are written to the response body.
      • setWebBindingInitializer

        public void setWebBindingInitializer(@Nullable
                                             WebBindingInitializer webBindingInitializer)
        Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.
      • getWebBindingInitializer

        public WebBindingInitializer getWebBindingInitializer()
        Return the configured WebBindingInitializer, or null if none.
      • setTaskExecutor

        public void setTaskExecutor(AsyncTaskExecutor taskExecutor)
        Set the default AsyncTaskExecutor to use when a controller method return a Callable. Controller methods can override this default on a per-request basis by returning an WebAsyncTask.

        By default a SimpleAsyncTaskExecutor instance is used. It's recommended to change that default in production as the simple executor does not re-use threads.

      • setAsyncRequestTimeout

        public void setAsyncRequestTimeout(long timeout)
        Specify the amount of time, in milliseconds, before concurrent handling should time out. In Servlet 3, the timeout begins after the main request processing thread has exited and ends when the request is dispatched again for further processing of the concurrently produced result.

        If this value is not set, the default timeout of the underlying implementation is used, e.g. 10 seconds on Tomcat with Servlet 3.

        timeout - the timeout value in milliseconds
      • setCallableInterceptors

        public void setCallableInterceptors(java.util.List<CallableProcessingInterceptor> interceptors)
        Configure CallableProcessingInterceptor's to register on async requests.
        interceptors - the interceptors to register
      • setDeferredResultInterceptors

        public void setDeferredResultInterceptors(java.util.List<DeferredResultProcessingInterceptor> interceptors)
        Configure DeferredResultProcessingInterceptor's to register on async requests.
        interceptors - the interceptors to register
      • setReactiveAdapterRegistry

        public void setReactiveAdapterRegistry(ReactiveAdapterRegistry reactiveAdapterRegistry)
        Configure the registry for reactive library types to be supported as return values from controller methods.
      • getReactiveAdapterRegistry

        public ReactiveAdapterRegistry getReactiveAdapterRegistry()
        Return the configured reactive type registry of adapters.
      • setIgnoreDefaultModelOnRedirect

        public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)
        By default the content of the "default" model is used both during rendering and redirect scenarios. Alternatively a controller method can declare a RedirectAttributes argument and use it to provide attributes for a redirect.

        Setting this flag to true guarantees the "default" model is never used in a redirect scenario even if a RedirectAttributes argument is not declared. Setting it to false means the "default" model may be used in a redirect if the controller method doesn't declare a RedirectAttributes argument.

        The default setting is false but new applications should consider setting it to true.

        See Also:
      • setSessionAttributeStore

        public void setSessionAttributeStore(SessionAttributeStore sessionAttributeStore)
        Specify the strategy to store session attributes with. The default is DefaultSessionAttributeStore, storing session attributes in the HttpSession with the same attribute name as in the model.
      • setCacheSecondsForSessionAttributeHandlers

        public void setCacheSecondsForSessionAttributeHandlers(int cacheSecondsForSessionAttributeHandlers)
        Cache content produced by @SessionAttributes annotated handlers for the given number of seconds.

        Possible values are:

        • -1: no generation of cache-related headers
        • 0 (default value): "Cache-Control: no-store" will prevent caching
        • 1 or higher: "Cache-Control: max-age=seconds" will ask to cache content; not advised when dealing with session attributes

        In contrast to the "cacheSeconds" property which will apply to all general handlers (but not to @SessionAttributes annotated handlers), this setting will apply to @SessionAttributes handlers only.

        See Also:
        WebContentGenerator.setCacheSeconds(int), SessionAttributes
      • setSynchronizeOnSession

        public void setSynchronizeOnSession(boolean synchronizeOnSession)
        Set if controller execution should be synchronized on the session, to serialize parallel invocations from the same client.

        More specifically, the execution of the handleRequestInternal method will get synchronized if this flag is "true". The best available session mutex will be used for the synchronization; ideally, this will be a mutex exposed by HttpSessionMutexListener.

        The session mutex is guaranteed to be the same object during the entire lifetime of the session, available under the key defined by the SESSION_MUTEX_ATTRIBUTE constant. It serves as a safe reference to synchronize on for locking on the current session.

        In many cases, the HttpSession reference itself is a safe mutex as well, since it will always be the same object reference for the same active logical session. However, this is not guaranteed across different servlet containers; the only 100% safe way is a session mutex.

        See Also:
        HttpSessionMutexListener, WebUtils.getSessionMutex(javax.servlet.http.HttpSession)
      • setParameterNameDiscoverer

        public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
        Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for default attribute names).

        Default is a DefaultParameterNameDiscoverer.

      • afterPropertiesSet

        public void afterPropertiesSet()
        Description copied from interface: InitializingBean
        Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

        This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

        Specified by:
        afterPropertiesSet in interface InitializingBean
      • supportsInternal

        protected boolean supportsInternal(HandlerMethod handlerMethod)
        Always return true since any method argument and return value type will be processed in some way. A method argument not recognized by any HandlerMethodArgumentResolver is interpreted as a request parameter if it is a simple type, or as a model attribute otherwise. A return value not recognized by any HandlerMethodReturnValueHandler will be interpreted as a model attribute.
        Specified by:
        supportsInternal in class AbstractHandlerMethodAdapter
        handlerMethod - the handler method to check
        whether or not this adapter can adapt the given method
      • createDataBinderFactory

        protected InitBinderDataBinderFactory createDataBinderFactory(java.util.List<InvocableHandlerMethod> binderMethods)
                                                               throws java.lang.Exception
        Template method to create a new InitBinderDataBinderFactory instance.

        The default implementation creates a ServletRequestDataBinderFactory. This can be overridden for custom ServletRequestDataBinder subclasses.

        binderMethods - @InitBinder methods
        the InitBinderDataBinderFactory instance to use
        java.lang.Exception - in case of invalid state or arguments