@SuppressWarnings({"unchecked", "rawtypes"})
    private ModelAndView handleResponseBody(Object returnValue,
                                            ServletWebRequest webRequest) throws ServletException, IOException {

        HttpInputMessage inputMessage = new ServletServerHttpRequest(
                webRequest.getRequest());
        List<MediaType> acceptedMediaTypes = inputMessage.getHeaders()
                .getAccept();
        if (acceptedMediaTypes.isEmpty()) {
            acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
        }
        MediaType.sortByQualityValue(acceptedMediaTypes);
        HttpOutputMessage outputMessage = new ServletServerHttpResponse(
                webRequest.getResponse());
        Class<?> returnValueType = returnValue.getClass();
        if (this.messageConverters != null) {
            for (MediaType acceptedMediaType : acceptedMediaTypes) {
                for (HttpMessageConverter messageConverter : this.messageConverters) {
                    if (messageConverter.canWrite(returnValueType,
                            acceptedMediaType)) {
                        messageConverter.write(returnValue, acceptedMediaType,
                                outputMessage);
                        return new ModelAndView();
                    }
                }
            }
        }
        if (logger.isWarnEnabled()) {
            logger.warn("Could not find HttpMessageConverter that supports return type ["
                    + returnValueType + "] and " + acceptedMediaTypes);
        }
        return null;
    }