Fix issue in ContentNeogitatingViewResolver

The following commit in 3.2.3 had a side effect on CNVR:
https://github.com/SpringSource/spring-framework/commit/aaded7e30b06cc70a354856a2288acd04045b673

It appears that CNVR doesn't treat a request for "*/*" differently
from a request that does not request content types. Both should be
interpreted as "any content type is acceptable". This fix ensures
that CNVR treats these two cases the same way.

Issue: SPR-10683
This commit is contained in:
Rossen Stoyanchev
2013-07-18 22:03:13 -04:00
parent a0f8a894f2
commit 7fdd0c22b2
2 changed files with 6 additions and 1 deletions
@@ -25,6 +25,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.activation.FileTypeMap;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -32,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.OrderComparator;
@@ -304,7 +304,11 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
protected List<MediaType> getMediaTypes(HttpServletRequest request) {
try {
ServletWebRequest webRequest = new ServletWebRequest(request);
List<MediaType> acceptableMediaTypes = this.contentNegotiationManager.resolveMediaTypes(webRequest);
acceptableMediaTypes = acceptableMediaTypes.isEmpty() ?
Collections.singletonList(MediaType.ALL) : acceptableMediaTypes;
List<MediaType> producibleMediaTypes = getProducibleMediaTypes(request);
Set<MediaType> compatibleMediaTypes = new LinkedHashSet<MediaType>();
for (MediaType acceptable : acceptableMediaTypes) {