Example usage for org.springframework.web.servlet HandlerMapping PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE

List of usage examples for org.springframework.web.servlet HandlerMapping PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE

Introduction

In this page you can find the example usage for org.springframework.web.servlet HandlerMapping PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE.

Prototype

String PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE

To view the source code for org.springframework.web.servlet HandlerMapping PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE.

Click Source Link

Document

Name of the HttpServletRequest attribute that contains the set of producible MediaTypes applicable to the mapped handler.

Usage

From source file:org.beadle.framework.view.ReturnTypeViewResolver.java

@SuppressWarnings("unchecked")
private List<MediaType> getProducibleMediaTypes(HttpServletRequest request) {
    Set<MediaType> mediaTypes = (Set<MediaType>) request
            .getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
    if (!CollectionUtils.isEmpty(mediaTypes)) {
        return new ArrayList<MediaType>(mediaTypes);
    } else {/*from  w  w w  .j ava 2 s  .  co  m*/
        return Collections.singletonList(MediaType.ALL);
    }
}

From source file:org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler.java

@SuppressWarnings("unchecked")
private Collection<MediaType> getMediaTypes(NativeWebRequest request)
        throws HttpMediaTypeNotAcceptableException {

    Collection<MediaType> mediaTypes = (Collection<MediaType>) request
            .getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

    return CollectionUtils.isEmpty(mediaTypes) ? this.contentNegotiationManager.resolveMediaTypes(request)
            : mediaTypes;/*w w  w.ja va  2  s  . c o  m*/
}