|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -60,7 +60,7 @@ import org.springframework.web.util.UriComponentsBuilder; |
|
|
|
public abstract class RequestContextUtils { |
|
|
|
public abstract class RequestContextUtils { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The name of the bean to use to look up in an implementation of |
|
|
|
* The name of the bean to use to determine if an implementation of |
|
|
|
* {@link RequestDataValueProcessor} has been configured. |
|
|
|
* {@link RequestDataValueProcessor} has been configured. |
|
|
|
* @since 4.2.1 |
|
|
|
* @since 4.2.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -119,10 +119,10 @@ public abstract class RequestContextUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the LocaleResolver that has been bound to the request by the |
|
|
|
* Return the {@link LocaleResolver} that has been bound to the request by the |
|
|
|
* DispatcherServlet. |
|
|
|
* {@link DispatcherServlet}. |
|
|
|
* @param request current HTTP request |
|
|
|
* @param request current HTTP request |
|
|
|
* @return the current LocaleResolver, or {@code null} if not found |
|
|
|
* @return the current {@code LocaleResolver}, or {@code null} if not found |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public static LocaleResolver getLocaleResolver(HttpServletRequest request) { |
|
|
|
public static LocaleResolver getLocaleResolver(HttpServletRequest request) { |
|
|
|
@ -131,8 +131,9 @@ public abstract class RequestContextUtils { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieve the current locale from the given request, using the |
|
|
|
* Retrieve the current locale from the given request, using the |
|
|
|
* LocaleResolver bound to the request by the DispatcherServlet |
|
|
|
* {@link LocaleResolver} bound to the request by the {@link DispatcherServlet} |
|
|
|
* (if available), falling back to the request's accept-header Locale. |
|
|
|
* (if available), falling back to the request's locale based on the |
|
|
|
|
|
|
|
* {@code Accept-Language} header or the default locale for the server. |
|
|
|
* <p>This method serves as a straightforward alternative to the standard |
|
|
|
* <p>This method serves as a straightforward alternative to the standard |
|
|
|
* Servlet {@link jakarta.servlet.http.HttpServletRequest#getLocale()} method, |
|
|
|
* Servlet {@link jakarta.servlet.http.HttpServletRequest#getLocale()} method, |
|
|
|
* falling back to the latter if no more specific locale has been found. |
|
|
|
* falling back to the latter if no more specific locale has been found. |
|
|
|
@ -151,18 +152,19 @@ public abstract class RequestContextUtils { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieve the current time zone from the given request, using the |
|
|
|
* Retrieve the current time zone from the given request, using the |
|
|
|
* TimeZoneAwareLocaleResolver bound to the request by the DispatcherServlet |
|
|
|
* {@link TimeZoneAwareLocaleContext} in the {@link LocaleResolver} bound to |
|
|
|
* (if available), falling back to the system's default time zone. |
|
|
|
* the request by the {@link DispatcherServlet} (if available). |
|
|
|
* <p>Note: This method returns {@code null} if no specific time zone can be |
|
|
|
* <p>Note: This method returns {@code null} if no specific time zone can be |
|
|
|
* resolved for the given request. This is in contrast to {@link #getLocale} |
|
|
|
* resolved for the given request. This is in contrast to {@link #getLocale} |
|
|
|
* where there is always the request's accept-header locale to fall back to. |
|
|
|
* where it is always possible to fall back to the request's locale based on the |
|
|
|
|
|
|
|
* {@code Accept-Language} header or the default locale for the server. |
|
|
|
* <p>Consider using {@link org.springframework.context.i18n.LocaleContextHolder#getTimeZone()} |
|
|
|
* <p>Consider using {@link org.springframework.context.i18n.LocaleContextHolder#getTimeZone()} |
|
|
|
* which will normally be populated with the same TimeZone: That method only |
|
|
|
* which will normally be populated with the same {@code TimeZone}: that method only |
|
|
|
* differs in terms of its fallback to the system time zone if the LocaleResolver |
|
|
|
* differs in terms of its fallback to the system time zone if the {@code LocaleResolver} |
|
|
|
* hasn't provided a specific time zone (instead of this method's {@code null}). |
|
|
|
* hasn't provided a specific time zone (instead of this method's {@code null}). |
|
|
|
* @param request current HTTP request |
|
|
|
* @param request current HTTP request |
|
|
|
* @return the current time zone for the given request, either from the |
|
|
|
* @return the current time zone for the given request, either from the |
|
|
|
* TimeZoneAwareLocaleResolver or {@code null} if none associated |
|
|
|
* {@code TimeZoneAwareLocaleContext} or {@code null} if none associated |
|
|
|
* @see #getLocaleResolver |
|
|
|
* @see #getLocaleResolver |
|
|
|
* @see org.springframework.context.i18n.LocaleContextHolder#getTimeZone() |
|
|
|
* @see org.springframework.context.i18n.LocaleContextHolder#getTimeZone() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -201,7 +203,7 @@ public abstract class RequestContextUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the current theme from the given request, using the ThemeResolver |
|
|
|
* Retrieve the current theme from the given request, using the ThemeResolver |
|
|
|
* and ThemeSource bound to the request by the DispatcherServlet. |
|
|
|
* and ThemeSource bound to the request by the DispatcherServlet. |
|
|
|
* @param request current HTTP request |
|
|
|
* @param request current HTTP request |
|
|
|
* @return the current theme, or {@code null} if not found |
|
|
|
* @return the current theme, or {@code null} if not found |
|
|
|
|