SPR-6686 - @ResponseBody throws HttpMediaTypeNotAcceptableException if client accepts "*/*"

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2814 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2010-01-15 10:23:59 +00:00
parent b695f63a0b
commit c3ab0ef473
8 changed files with 167 additions and 12 deletions
@@ -864,6 +864,9 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
if (acceptedMediaTypes.isEmpty()) {
acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
}
else {
Collections.sort(acceptedMediaTypes);
}
HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
Class<?> returnValueType = returnValue.getClass();
List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
@@ -872,7 +875,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
for (MediaType acceptedMediaType : acceptedMediaTypes) {
if (messageConverter.canWrite(returnValueType, acceptedMediaType)) {
messageConverter.write(returnValue, null, outputMessage);
messageConverter.write(returnValue, acceptedMediaType, outputMessage);
this.responseArgumentUsed = true;
return;
}