first bunch of backports from 3.1 M2 to 3.0.6

This commit is contained in:
Juergen Hoeller
2011-06-08 22:49:41 +00:00
parent 175f6d4bc5
commit ca19b14f13
31 changed files with 498 additions and 300 deletions

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,13 +16,11 @@
package org.springframework.web.servlet.i18n;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.support.RequestContextUtils;
@@ -72,9 +70,7 @@ public class LocaleChangeInterceptor extends HandlerInterceptorAdapter {
if (localeResolver == null) {
throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
}
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(newLocale);
localeResolver.setLocale(request, response, (Locale) localeEditor.getValue());
localeResolver.setLocale(request, response, StringUtils.parseLocaleString(newLocale));
}
// Proceed in any case.
return true;

View File

@@ -35,9 +35,9 @@ import org.springframework.web.servlet.support.WebContentGenerator;
/**
* {@link HttpRequestHandler} that serves static resources optimized for superior browser performance
* (according to the guidelines of Page Speed, YSlow, etc.) by allowing for flexible cache settings
* ({@link #setCacheSeconds "cacheSeconds" property}, last-modified support).
* ({@linkplain #setCacheSeconds "cacheSeconds" property}, last-modified support).
*
* <p>The {@link #setLocations "locations" property takes a list of Spring {@link Resource} locations
* <p>The {@linkplain #setLocations "locations" property} takes a list of Spring {@link Resource} locations
* from which static resources are allowed to be served by this handler. For a given request, the
* list of locations will be consulted in order for the presence of the requested resource, and the
* first found match will be written to the response, with {@code Expires} and {@code Cache-Control}
@@ -54,7 +54,7 @@ import org.springframework.web.servlet.support.WebContentGenerator;
* using Spring EL. See the reference manual for further examples of this approach.
*
* <p>Rather than being directly configured as a bean, this handler will typically be configured
* through use of the <code>&lt;mvc:resources/&gt;</code> XML configuration element.
* through use of the {@code <mvc:resources/>} XML configuration element.
*
* @author Keith Donald
* @author Jeremy Grelle
@@ -121,11 +121,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator implements H
}
// header phase
setHeaders(response, resource, mediaType);
if (new ServletWebRequest(request, response).checkNotModified(resource.lastModified())) {
logger.debug("Resource not modified - returning 304");
return;
}
setHeaders(response, resource, mediaType);
// content phase
if (METHOD_HEAD.equals(request.getMethod())) {