Search in sources :

Example 6 with ModelMethodProcessor

use of org.springframework.web.method.annotation.ModelMethodProcessor in project spring-framework by spring-projects.

the class RequestMappingHandlerAdapter method getDefaultReturnValueHandlers.

/**
	 * Return the list of return value handlers to use including built-in and
	 * custom handlers provided via {@link #setReturnValueHandlers}.
	 */
private List<HandlerMethodReturnValueHandler> getDefaultReturnValueHandlers() {
    List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>();
    // Single-purpose return value types
    handlers.add(new ModelAndViewMethodReturnValueHandler());
    handlers.add(new ModelMethodProcessor());
    handlers.add(new ViewMethodReturnValueHandler());
    handlers.add(new ResponseBodyEmitterReturnValueHandler(getMessageConverters()));
    handlers.add(new StreamingResponseBodyReturnValueHandler());
    handlers.add(new HttpEntityMethodProcessor(getMessageConverters(), this.contentNegotiationManager, this.requestResponseBodyAdvice));
    handlers.add(new HttpHeadersReturnValueHandler());
    handlers.add(new CallableMethodReturnValueHandler());
    handlers.add(new DeferredResultMethodReturnValueHandler());
    handlers.add(new AsyncTaskMethodReturnValueHandler(this.beanFactory));
    // Annotation-based return value types
    handlers.add(new ModelAttributeMethodProcessor(false));
    handlers.add(new RequestResponseBodyMethodProcessor(getMessageConverters(), this.contentNegotiationManager, this.requestResponseBodyAdvice));
    // Multi-purpose return value types
    handlers.add(new ViewNameMethodReturnValueHandler());
    handlers.add(new MapMethodProcessor());
    // Custom return value types
    if (getCustomReturnValueHandlers() != null) {
        handlers.addAll(getCustomReturnValueHandlers());
    }
    // Catch-all
    if (!CollectionUtils.isEmpty(getModelAndViewResolvers())) {
        handlers.add(new ModelAndViewResolverMethodReturnValueHandler(getModelAndViewResolvers()));
    } else {
        handlers.add(new ModelAttributeMethodProcessor(true));
    }
    return handlers;
}
Also used : HandlerMethodReturnValueHandler(org.springframework.web.method.support.HandlerMethodReturnValueHandler) ModelMethodProcessor(org.springframework.web.method.annotation.ModelMethodProcessor) ArrayList(java.util.ArrayList) MapMethodProcessor(org.springframework.web.method.annotation.MapMethodProcessor) ModelAttributeMethodProcessor(org.springframework.web.method.annotation.ModelAttributeMethodProcessor)

Example 7 with ModelMethodProcessor

use of org.springframework.web.method.annotation.ModelMethodProcessor in project spring-framework by spring-projects.

the class ExceptionHandlerExceptionResolverTests method setReturnValueHandlers.

@Test
public void setReturnValueHandlers() {
    HandlerMethodReturnValueHandler handler = new ModelMethodProcessor();
    this.resolver.setReturnValueHandlers(Collections.singletonList(handler));
    this.resolver.afterPropertiesSet();
    assertMethodProcessorCount(RESOLVER_COUNT, 1);
}
Also used : HandlerMethodReturnValueHandler(org.springframework.web.method.support.HandlerMethodReturnValueHandler) ModelMethodProcessor(org.springframework.web.method.annotation.ModelMethodProcessor) Test(org.junit.Test)

Aggregations

ModelMethodProcessor (org.springframework.web.method.annotation.ModelMethodProcessor)7 HandlerMethodReturnValueHandler (org.springframework.web.method.support.HandlerMethodReturnValueHandler)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 MapMethodProcessor (org.springframework.web.method.annotation.MapMethodProcessor)3 HandlerMethodArgumentResolver (org.springframework.web.method.support.HandlerMethodArgumentResolver)3 ModelAttributeMethodProcessor (org.springframework.web.method.annotation.ModelAttributeMethodProcessor)2 HandlerMethod (org.springframework.web.method.HandlerMethod)1 ErrorsMethodArgumentResolver (org.springframework.web.method.annotation.ErrorsMethodArgumentResolver)1 ExpressionValueMethodArgumentResolver (org.springframework.web.method.annotation.ExpressionValueMethodArgumentResolver)1 RequestHeaderMapMethodArgumentResolver (org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentResolver)1 RequestHeaderMethodArgumentResolver (org.springframework.web.method.annotation.RequestHeaderMethodArgumentResolver)1 RequestParamMapMethodArgumentResolver (org.springframework.web.method.annotation.RequestParamMapMethodArgumentResolver)1 RequestParamMethodArgumentResolver (org.springframework.web.method.annotation.RequestParamMethodArgumentResolver)1 SessionStatusMethodArgumentResolver (org.springframework.web.method.annotation.SessionStatusMethodArgumentResolver)1 InvocableHandlerMethod (org.springframework.web.method.support.InvocableHandlerMethod)1 FlashMap (org.springframework.web.servlet.FlashMap)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1