@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2015 the original author or authors .
* Copyright 2002 - 2016 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 .
@ -27,18 +27,15 @@ import org.springframework.web.HttpMediaTypeNotAcceptableException;
@@ -27,18 +27,15 @@ import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.context.request.NativeWebRequest ;
/ * *
* A { @code ContentNegotiationStrategy } that resolves a query parameter to a
* key to be used to look up a media type . The default parameter name is
* { @code format } .
* s
* A { @code ContentNegotiationStrategy } that resolves a query parameter to a key
* to be used to look up a media type . The default parameter name is { @code format } .
*
* @author Rossen Stoyanchev
* @since 3 . 2
* /
public class ParameterContentNegotiationStrategy
extends AbstractMappingContentNegotiationStrategy {
public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy {
private static final Log logger = LogFactory . getLog (
ParameterContentNegotiationStrategy . class ) ;
private static final Log logger = LogFactory . getLog ( ParameterContentNegotiationStrategy . class ) ;
private String parameterName = "format" ;
@ -56,7 +53,7 @@ public class ParameterContentNegotiationStrategy
@@ -56,7 +53,7 @@ public class ParameterContentNegotiationStrategy
* < p > By default this is set to { @code "format" } .
* /
public void setParameterName ( String parameterName ) {
Assert . notNull ( parameterName , "parameterName is required" ) ;
Assert . notNull ( parameterName , "' parameterName' is required" ) ;
this . parameterName = parameterName ;
}
@ -64,6 +61,7 @@ public class ParameterContentNegotiationStrategy
@@ -64,6 +61,7 @@ public class ParameterContentNegotiationStrategy
return this . parameterName ;
}
@Override
protected String getMediaTypeKey ( NativeWebRequest request ) {
return request . getParameter ( getParameterName ( ) ) ;
@ -72,8 +70,8 @@ public class ParameterContentNegotiationStrategy
@@ -72,8 +70,8 @@ public class ParameterContentNegotiationStrategy
@Override
protected void handleMatch ( String mediaTypeKey , MediaType mediaType ) {
if ( logger . isDebugEnabled ( ) ) {
logger . debug ( "Requested media type is '" + mediaType +
"' based on '" + getParameterName ( ) + "'='" + mediaTypeKey + "'. " ) ;
logger . debug ( "Requested media type: '" + mediaType + "' based on '" +
getParameterName ( ) + "'='" + mediaTypeKey + "'" ) ;
}
}