public class SafeRequestContext
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
DEFAULT_THEME_NAME |
private java.lang.Boolean |
defaultHtmlEscape |
private java.util.Map<java.lang.String,org.springframework.validation.Errors> |
errorsMap |
private java.util.Locale |
locale |
private java.util.Map<java.lang.String,java.lang.Object> |
model |
private javax.servlet.http.HttpServletRequest |
request |
private org.springframework.web.servlet.support.RequestDataValueProcessor |
requestDataValueProcessor |
private javax.servlet.http.HttpServletResponse |
response |
private java.lang.Boolean |
responseEncodedHtmlEscape |
private org.springframework.ui.context.Theme |
theme |
private java.util.TimeZone |
timeZone |
private org.springframework.web.util.UrlPathHelper |
urlPathHelper |
static java.lang.String |
WEB_APPLICATION_CONTEXT_ATTRIBUTE |
private org.springframework.web.context.WebApplicationContext |
webApplicationContext |
构造器和说明 |
---|
SafeRequestContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.ServletContext servletContext,
java.util.Map<java.lang.String,java.lang.Object> model) |
限定符和类型 | 方法和说明 |
---|---|
void |
changeLocale(java.util.Locale locale) |
void |
changeLocale(java.util.Locale locale,
java.util.TimeZone timeZone) |
void |
changeTheme(java.lang.String themeName) |
void |
changeTheme(org.springframework.ui.context.Theme theme) |
java.lang.String |
getContextPath() |
java.lang.String |
getContextUrl(java.lang.String relativeUrl) |
java.lang.String |
getContextUrl(java.lang.String relativeUrl,
java.util.Map<java.lang.String,?> params) |
java.lang.Boolean |
getDefaultHtmlEscape() |
org.springframework.validation.Errors |
getErrors(java.lang.String name) |
org.springframework.validation.Errors |
getErrors(java.lang.String name,
boolean htmlEscape) |
protected java.util.Locale |
getFallbackLocale() |
protected org.springframework.ui.context.Theme |
getFallbackTheme() |
protected java.util.TimeZone |
getFallbackTimeZone() |
java.util.Locale |
getLocale() |
java.lang.String |
getMessage(org.springframework.context.MessageSourceResolvable resolvable) |
java.lang.String |
getMessage(org.springframework.context.MessageSourceResolvable resolvable,
boolean htmlEscape) |
java.lang.String |
getMessage(java.lang.String code) |
java.lang.String |
getMessage(java.lang.String code,
java.util.List<?> args) |
java.lang.String |
getMessage(java.lang.String code,
java.util.List<?> args,
java.lang.String defaultMessage) |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args) |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
boolean htmlEscape) |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage) |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
boolean htmlEscape) |
java.lang.String |
getMessage(java.lang.String code,
java.lang.String defaultMessage) |
java.util.Map<java.lang.String,java.lang.Object> |
getModel() |
protected java.lang.Object |
getModelObject(java.lang.String modelName) |
java.lang.String |
getPathToServlet() |
java.lang.String |
getQueryString() |
protected javax.servlet.http.HttpServletRequest |
getRequest() |
org.springframework.web.servlet.support.RequestDataValueProcessor |
getRequestDataValueProcessor() |
java.lang.String |
getRequestUri() |
java.lang.Boolean |
getResponseEncodedHtmlEscape() |
protected javax.servlet.ServletContext |
getServletContext()
Return the underlying ServletContext.
|
org.springframework.ui.context.Theme |
getTheme() |
java.lang.String |
getThemeMessage(org.springframework.context.MessageSourceResolvable resolvable) |
java.lang.String |
getThemeMessage(java.lang.String code) |
java.lang.String |
getThemeMessage(java.lang.String code,
java.util.List<?> args) |
java.lang.String |
getThemeMessage(java.lang.String code,
java.util.List<?> args,
java.lang.String defaultMessage) |
java.lang.String |
getThemeMessage(java.lang.String code,
java.lang.Object[] args) |
java.lang.String |
getThemeMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage) |
java.lang.String |
getThemeMessage(java.lang.String code,
java.lang.String defaultMessage) |
java.util.TimeZone |
getTimeZone() |
org.springframework.web.util.UrlPathHelper |
getUrlPathHelper() |
boolean |
isDefaultHtmlEscape() |
boolean |
isResponseEncodedHtmlEscape() |
void |
setDefaultHtmlEscape(boolean defaultHtmlEscape) |
void |
setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper) |
public static final java.lang.String DEFAULT_THEME_NAME
public static final java.lang.String WEB_APPLICATION_CONTEXT_ATTRIBUTE
private javax.servlet.http.HttpServletRequest request
@Nullable private javax.servlet.http.HttpServletResponse response
@Nullable private java.util.Map<java.lang.String,java.lang.Object> model
private org.springframework.web.context.WebApplicationContext webApplicationContext
@Nullable private java.util.Locale locale
@Nullable private java.util.TimeZone timeZone
@Nullable private org.springframework.ui.context.Theme theme
@Nullable private java.lang.Boolean defaultHtmlEscape
@Nullable private java.lang.Boolean responseEncodedHtmlEscape
private org.springframework.web.util.UrlPathHelper urlPathHelper
@Nullable private org.springframework.web.servlet.support.RequestDataValueProcessor requestDataValueProcessor
@Nullable private java.util.Map<java.lang.String,org.springframework.validation.Errors> errorsMap
public SafeRequestContext(javax.servlet.http.HttpServletRequest request, @Nullable javax.servlet.http.HttpServletResponse response, @Nullable javax.servlet.ServletContext servletContext, @Nullable java.util.Map<java.lang.String,java.lang.Object> model)
protected final javax.servlet.http.HttpServletRequest getRequest()
@Nullable protected final javax.servlet.ServletContext getServletContext()
@Nullable public final java.util.Map<java.lang.String,java.lang.Object> getModel()
null
if none availablepublic final java.util.Locale getLocale()
null
)@Nullable public java.util.TimeZone getTimeZone()
null
)protected java.util.Locale getFallbackLocale()
null
)@Nullable protected java.util.TimeZone getFallbackTimeZone()
null
if none derivable from
the request)public void changeLocale(java.util.Locale locale)
locale
- the new localepublic void changeLocale(java.util.Locale locale, java.util.TimeZone timeZone)
locale
- the new localetimeZone
- the new time zonepublic org.springframework.ui.context.Theme getTheme()
null
).protected org.springframework.ui.context.Theme getFallbackTheme()
null
)public void changeTheme(@Nullable org.springframework.ui.context.Theme theme)
theme
- the new themeThemeResolver.setThemeName(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
public void changeTheme(java.lang.String themeName)
themeName
- the name of the new themeThemeResolver.setThemeName(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
public void setDefaultHtmlEscape(boolean defaultHtmlEscape)
defaultHtmlEscape
- public boolean isDefaultHtmlEscape()
false
in
case of no explicit default given.@Nullable public java.lang.Boolean getDefaultHtmlEscape()
public boolean isResponseEncodedHtmlEscape()
@Nullable public java.lang.Boolean getResponseEncodedHtmlEscape()
public void setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper)
urlPathHelper
- public org.springframework.web.util.UrlPathHelper getUrlPathHelper()
@Nullable public org.springframework.web.servlet.support.RequestDataValueProcessor getRequestDataValueProcessor()
"requestDataValueProcessor"
. Or null
if no
matching bean was found.public java.lang.String getContextPath()
public java.lang.String getContextUrl(java.lang.String relativeUrl)
relativeUrl
- the relative URL partpublic java.lang.String getContextUrl(java.lang.String relativeUrl, java.util.Map<java.lang.String,?> params)
relativeUrl
- the relative URL partparams
- a map of parameters to insert as placeholders in the urlpublic java.lang.String getPathToServlet()
public java.lang.String getRequestUri()
public java.lang.String getQueryString()
public java.lang.String getMessage(java.lang.String code, java.lang.String defaultMessage)
code
- the code of the messagedefaultMessage
- the String to return if the lookup failspublic java.lang.String getMessage(java.lang.String code, @Nullable java.lang.Object[] args, java.lang.String defaultMessage)
code
- the code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- the String to return if the lookup failspublic java.lang.String getMessage(java.lang.String code, @Nullable java.util.List<?> args, java.lang.String defaultMessage)
code
- the code of the messageargs
- arguments for the message as a List, or null
if nonedefaultMessage
- the String to return if the lookup failspublic java.lang.String getMessage(java.lang.String code, @Nullable java.lang.Object[] args, java.lang.String defaultMessage, boolean htmlEscape)
code
- the code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- the String to return if the lookup failshtmlEscape
- if the message should be HTML-escapedpublic java.lang.String getMessage(java.lang.String code) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, @Nullable java.lang.Object[] args) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageargs
- arguments for the message, or null
if noneorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, @Nullable java.util.List<?> args) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageargs
- arguments for the message as a List, or null
if noneorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getMessage(java.lang.String code, @Nullable java.lang.Object[] args, boolean htmlEscape) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageargs
- arguments for the message, or null
if nonehtmlEscape
- if the message should be HTML-escapedorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable) throws org.springframework.context.NoSuchMessageException
resolvable
- the MessageSourceResolvableorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable, boolean htmlEscape) throws org.springframework.context.NoSuchMessageException
resolvable
- the MessageSourceResolvablehtmlEscape
- if the message should be HTML-escapedorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getThemeMessage(java.lang.String code, java.lang.String defaultMessage)
code
- the code of the messagedefaultMessage
- the String to return if the lookup failspublic java.lang.String getThemeMessage(java.lang.String code, @Nullable java.lang.Object[] args, java.lang.String defaultMessage)
code
- the code of the messageargs
- arguments for the message, or null
if nonedefaultMessage
- the String to return if the lookup failspublic java.lang.String getThemeMessage(java.lang.String code, @Nullable java.util.List<?> args, java.lang.String defaultMessage)
code
- the code of the messageargs
- arguments for the message as a List, or null
if nonedefaultMessage
- the String to return if the lookup failspublic java.lang.String getThemeMessage(java.lang.String code) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getThemeMessage(java.lang.String code, @Nullable java.lang.Object[] args) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageargs
- arguments for the message, or null
if noneorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getThemeMessage(java.lang.String code, @Nullable java.util.List<?> args) throws org.springframework.context.NoSuchMessageException
code
- the code of the messageargs
- arguments for the message as a List, or null
if noneorg.springframework.context.NoSuchMessageException
- if not foundpublic java.lang.String getThemeMessage(org.springframework.context.MessageSourceResolvable resolvable) throws org.springframework.context.NoSuchMessageException
resolvable
- the MessageSourceResolvableorg.springframework.context.NoSuchMessageException
- if not found@Nullable public org.springframework.validation.Errors getErrors(java.lang.String name)
name
- the name of the bind objectnull
if not found@Nullable public org.springframework.validation.Errors getErrors(java.lang.String name, boolean htmlEscape)
name
- the name of the bind objecthtmlEscape
- create an Errors instance with automatic HTML escaping?null
if not found@Nullable protected java.lang.Object getModelObject(java.lang.String modelName)
modelName
- the name of the model object