SPR-8678 Use the lookup path to determine the media type by file name.
This commit is contained in:
parent
2799e710bc
commit
de504fa613
|
|
@ -314,7 +314,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
|
||||||
*/
|
*/
|
||||||
protected List<MediaType> getMediaTypes(HttpServletRequest request) {
|
protected List<MediaType> getMediaTypes(HttpServletRequest request) {
|
||||||
if (this.favorPathExtension) {
|
if (this.favorPathExtension) {
|
||||||
String requestUri = urlPathHelper.getRequestUri(request);
|
String requestUri = urlPathHelper.getLookupPathForRequest(request);
|
||||||
String filename = WebUtils.extractFullFilenameFromUrlPath(requestUri);
|
String filename = WebUtils.extractFullFilenameFromUrlPath(requestUri);
|
||||||
MediaType mediaType = getMediaTypeFromFilename(filename);
|
MediaType mediaType = getMediaTypeFromFilename(filename);
|
||||||
if (mediaType != null) {
|
if (mediaType != null) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,17 @@ public class ContentNegotiatingViewResolverTests {
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPR-8678
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMediaTypeFilenameWithContextPath() {
|
||||||
|
request.setContextPath("/project-1.0.0.M3");
|
||||||
|
request.setRequestURI("/project-1.0.0.M3/");
|
||||||
|
assertTrue("Context path should be excluded", viewResolver.getMediaTypes(request).isEmpty());
|
||||||
|
request.setRequestURI("/project-1.0.0.M3");
|
||||||
|
assertTrue("Context path should be excluded", viewResolver.getMediaTypes(request).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMediaTypeParameter() {
|
public void getMediaTypeParameter() {
|
||||||
viewResolver.setFavorParameter(true);
|
viewResolver.setFavorParameter(true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue