SPR-7353 - @ResponseBody and returned HttpEntity now respect @RequestMapping.produces()

This commit is contained in:
Arjen Poutsma
2011-05-17 09:45:57 +00:00
parent 57c757afc5
commit ad2e0d4587
12 changed files with 396 additions and 219 deletions

View File

@@ -322,7 +322,7 @@ public class MediaType implements Comparable<MediaType> {
}
/**
* Indicate whether the {@linkplain #getType() type} is the wildcard character <code>&#42;</code> or not.
* Indicates whether the {@linkplain #getType() type} is the wildcard character <code>&#42;</code> or not.
*/
public boolean isWildcardType() {
return WILDCARD_TYPE.equals(type);
@@ -336,13 +336,22 @@ public class MediaType implements Comparable<MediaType> {
}
/**
* Indicate whether the {@linkplain #getSubtype() subtype} is the wildcard character <code>&#42;</code> or not.
* Indicates whether the {@linkplain #getSubtype() subtype} is the wildcard character <code>&#42;</code> or not.
* @return whether the subtype is <code>&#42;</code>
*/
public boolean isWildcardSubtype() {
return WILDCARD_TYPE.equals(subtype);
}
/**
* Indicates whether this media type is concrete, i.e. whether neither the type or subtype is a wildcard
* character <code>&#42;</code>.
* @return whether this media type is concrete
*/
public boolean isConcrete() {
return !isWildcardType() && !isWildcardSubtype();
}
/**
* Return the character set, as indicated by a <code>charset</code> parameter, if any.
* @return the character set; or <code>null</code> if not available

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.web;
import java.util.Collection;
import javax.servlet.ServletException;
/**
@@ -49,6 +50,15 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
this(method, supportedMethods, "Request method '" + method + "' not supported");
}
/**
* Create a new HttpRequestMethodNotSupportedException.
* @param method the unsupported HTTP request method
* @param supportedMethods the actually supported HTTP methods
*/
public HttpRequestMethodNotSupportedException(String method, Collection<String> supportedMethods) {
this(method, supportedMethods.toArray(new String[supportedMethods.size()]));
}
/**
* Create a new HttpRequestMethodNotSupportedException.
* @param method the unsupported HTTP request method