Skip to content

Commit e0f9a85

Browse files
committed
Locale/ThemeChangeInterceptor alignment and javadoc polishing
Issue: SPR-11128 (cherry picked from commit 5e5add4)
1 parent b229d54 commit e0f9a85

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,14 +17,13 @@
1717
package org.springframework.web.servlet.i18n;
1818

1919
import java.util.Locale;
20-
2120
import javax.servlet.http.HttpServletRequest;
2221
import javax.servlet.http.HttpServletResponse;
2322

2423
import org.springframework.web.servlet.LocaleResolver;
2524

2625
/**
27-
* Implementation of LocaleResolver that simply uses the primary locale
26+
* {@link LocaleResolver} implementation that simply uses the primary locale
2827
* specified in the "accept-language" header of the HTTP request (that is,
2928
* the locale sent by the client browser, normally that of the client's OS).
3029
*

spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
2727

2828
/**
2929
* Interceptor that allows for changing the current locale on every request,
30-
* via a configurable request parameter.
30+
* via a configurable request parameter (default parameter name: "locale").
3131
*
3232
* @author Juergen Hoeller
3333
* @since 20.06.2003

spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/SessionLocaleResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
import org.springframework.web.util.WebUtils;
2525

2626
/**
27-
* Implementation of LocaleResolver that uses a locale attribute in the user's
28-
* session in case of a custom setting, with a fallback to the specified default
29-
* locale or the request's accept-header locale.
27+
* {@link org.springframework.web.servlet.LocaleResolver} implementation that
28+
* uses a locale attribute in the user's session in case of a custom setting,
29+
* with a fallback to the specified default locale or the request's
30+
* accept-header locale.
3031
*
3132
* <p>This is most appropriate if the application needs user sessions anyway,
3233
* that is, when the HttpSession does not have to be created for the locale.

spring-webmvc/src/main/java/org/springframework/web/servlet/theme/FixedThemeResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,8 +20,9 @@
2020
import javax.servlet.http.HttpServletResponse;
2121

2222
/**
23-
* Implementation of ThemeResolver that simply uses a fixed theme.
24-
* The fixed name can be defined via the "defaultThemeName" property.
23+
* {@link org.springframework.web.servlet.ThemeResolver} implementation
24+
* that simply uses a fixed theme. The fixed name can be defined via
25+
* the "defaultThemeName" property; out of the box, it is "theme".
2526
*
2627
* <p>Note: Does not support {@code setThemeName}, as the fixed theme
2728
* cannot be changed.

spring-webmvc/src/main/java/org/springframework/web/servlet/theme/ThemeChangeInterceptor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* Interceptor that allows for changing the current theme on every request,
29-
* via a configurable request parameter.
29+
* via a configurable request parameter (default parameter name: "theme").
3030
*
3131
* @author Juergen Hoeller
3232
* @since 20.06.2003
@@ -63,12 +63,12 @@ public String getParamName() {
6363
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
6464
throws ServletException {
6565

66-
ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request);
67-
if (themeResolver == null) {
68-
throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?");
69-
}
7066
String newTheme = request.getParameter(this.paramName);
7167
if (newTheme != null) {
68+
ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request);
69+
if (themeResolver == null) {
70+
throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?");
71+
}
7272
themeResolver.setThemeName(request, response, newTheme);
7373
}
7474
// Proceed in any case.

0 commit comments

Comments
 (0)