接口 ThemeResolver
public interface ThemeResolver
Interface for web-based theme resolution strategies that allows for both theme resolution via the request and theme modification via request and response.This interface allows for implementations based on session, cookies, etc. The default implementation is
FixedThemeResolver
, simply using a configured default theme.Note that this resolver is only responsible for determining the current theme name. The Theme instance for the resolved theme name gets looked up by DispatcherServlet via the respective ThemeSource, i.e. the current WebApplicationContext.
Use
RequestContext.getTheme()
to retrieve the current theme in controllers or views, independent of the actual resolution strategy.- 从以下版本开始:
- 17.06.2003
- 作者:
- Jean-Pierre Pawlak, Juergen Hoeller
- 另请参阅:
Theme
,ThemeSource
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 String
resolveThemeName(HttpServletRequest request)
Resolve the current theme name via the given request.void
setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName)
Set the current theme name to the given one.
方法详细资料
resolveThemeName
String resolveThemeName(HttpServletRequest request)
Resolve the current theme name via the given request. Should return a default theme as fallback in any case.- 参数:
request
- the request to be used for resolution- 返回:
- the current theme name
setThemeName
void setThemeName(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable String themeName)
Set the current theme name to the given one.- 参数:
request
- the request to be used for theme name modificationresponse
- the response to be used for theme name modificationthemeName
- the new theme name (null
or empty to reset it)- 抛出:
UnsupportedOperationException
- if the ThemeResolver implementation does not support dynamic changing of the theme