Example usage for org.springframework.web.servlet.view AbstractView getContentType

List of usage examples for org.springframework.web.servlet.view AbstractView getContentType

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view AbstractView getContentType.

Prototype

@Override
@Nullable
public String getContentType() 

Source Link

Document

Return the content type for this view.

Usage

From source file:com.asual.summer.core.spring.ViewResolverConfiguration.java

public AbstractView handleViews(Collection<AbstractView> views, NativeWebRequest request) {
    List<MediaType> requestedMediaTypes;
    try {//  w ww  . j a v  a2 s  .  c o m
        requestedMediaTypes = contentNegotiationManager.resolveMediaTypes(request);
        for (MediaType requestedMediaType : requestedMediaTypes) {
            for (AbstractView view : views) {
                MediaType producableMediaType = MediaType.parseMediaType(view.getContentType());
                if (requestedMediaType.isCompatibleWith(producableMediaType)
                        && !requestedMediaType.isWildcardType() && requestedMediaType.getQualityValue() > 0.9) {
                    return view;
                }
            }

        }
    } catch (HttpMediaTypeNotAcceptableException e) {
        logger.debug(e.getMessage(), e);
    }
    return null;
}