public class WebUtils
extends org.springframework.web.util.WebUtils
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DISPATCH_ACTION_PARAMETER |
static java.lang.String |
ENABLE_FILE_EXTENSIONS |
static java.lang.String |
EXCEPTION_ATTRIBUTE |
static java.lang.String |
GRAILS_DISPATCH_EXTENSION |
static java.lang.String |
GRAILS_SERVLET_PATH |
static java.lang.String |
LAYOUT_ATTRIBUTE |
static java.lang.String |
RENDERING_VIEW |
static java.lang.String |
SEND_ALLOW_HEADER_FOR_INVALID_HTTP_METHOD |
static char |
SLASH |
CONTENT_TYPE_CHARSET_PREFIX, DEFAULT_CHARACTER_ENCODING, DEFAULT_WEB_APP_ROOT_KEY, ERROR_EXCEPTION_ATTRIBUTE, ERROR_EXCEPTION_TYPE_ATTRIBUTE, ERROR_MESSAGE_ATTRIBUTE, ERROR_REQUEST_URI_ATTRIBUTE, ERROR_SERVLET_NAME_ATTRIBUTE, ERROR_STATUS_CODE_ATTRIBUTE, FORWARD_CONTEXT_PATH_ATTRIBUTE, FORWARD_PATH_INFO_ATTRIBUTE, FORWARD_QUERY_STRING_ATTRIBUTE, FORWARD_REQUEST_URI_ATTRIBUTE, FORWARD_SERVLET_PATH_ATTRIBUTE, HTML_ESCAPE_CONTEXT_PARAM, INCLUDE_CONTEXT_PATH_ATTRIBUTE, INCLUDE_PATH_INFO_ATTRIBUTE, INCLUDE_QUERY_STRING_ATTRIBUTE, INCLUDE_REQUEST_URI_ATTRIBUTE, INCLUDE_SERVLET_PATH_ATTRIBUTE, RESPONSE_ENCODED_HTML_ESCAPE_CONTEXT_PARAM, SESSION_MUTEX_ATTRIBUTE, SUBMIT_IMAGE_SUFFIXES, TEMP_DIR_CONTEXT_ATTRIBUTE, WEB_APP_ROOT_KEY_PARAM| Constructor and Description |
|---|
WebUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
addViewPrefix(java.lang.String viewName) |
static java.lang.String |
addViewPrefix(java.lang.String viewName,
java.lang.String controllerName) |
static boolean |
areFileExtensionsEnabled()
Returns the value of the "grails.mime.file.extensions" setting configured in COnfig.groovy
|
static void |
cleanupIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request,
java.util.Map<java.lang.String,java.lang.Object> toRestore) |
static void |
clearGrailsWebRequest()
Removes any GrailsWebRequest instance from the current request.
|
static void |
exposeIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request)
Expose the current request URI and paths as
HttpServletRequest
attributes under the keys defined in the Servlet 2.4 specification,
for containers that implement 2.3 or an earlier version of the Servlet API:
javax.servlet.forward.request_uri,
javax.servlet.forward.context_path,
javax.servlet.forward.servlet_path,
javax.servlet.forward.path_info,
javax.servlet.forward.query_string. |
static java.util.Map<java.lang.String,java.lang.Object> |
exposeRequestAttributesAndReturnOldValues(javax.servlet.http.HttpServletRequest request,
java.util.Map<java.lang.String,?> attributes) |
static org.springframework.context.ApplicationContext |
findApplicationContext(javax.servlet.ServletContext servletContext)
Locates the ApplicationContext, returns null if not found
|
static java.util.Map<java.lang.String,java.lang.Object> |
fromQueryString(java.lang.String queryString)
Takes a query string and returns the results as a map where the values are either a single entry or a list of values
|
static java.lang.String |
getFormatFromURI(java.lang.String uri)
Obtains the format from the URI.
|
static java.lang.String |
getFormatFromURI(java.lang.String uri,
org.codehaus.groovy.grails.web.mime.MimeType[] mimeTypes)
Obtains the format from the URI.
|
static java.lang.String |
getForwardURI(javax.servlet.http.HttpServletRequest request)
Obtains the forwardURI from the request, since Grails uses a forwarding technique for URL mappings.
|
static java.lang.String |
getRequestURIForGrailsDispatchURI(javax.servlet.http.HttpServletRequest request)
The Grails dispatch servlet maps URIs like /app/grails/example/index.dispatch.
|
static org.codehaus.groovy.grails.commons.GrailsApplication |
lookupApplication(javax.servlet.ServletContext servletContext)
Looks up the GrailsApplication instance
|
static org.springframework.web.servlet.HandlerInterceptor[] |
lookupHandlerInterceptors(javax.servlet.ServletContext servletContext)
Looks up all of the HandlerInterceptor instances registered for the application
|
static org.springframework.web.servlet.ViewResolver |
lookupViewResolver(org.springframework.context.ApplicationContext wac) |
static org.springframework.web.servlet.ViewResolver |
lookupViewResolver(javax.servlet.ServletContext servletContext) |
static org.springframework.web.context.request.WebRequestInterceptor[] |
lookupWebRequestInterceptors(javax.servlet.ServletContext servletContext)
Looks up all of the WebRequestInterceptor instances registered with the application
|
static org.springframework.web.servlet.View |
resolveView(javax.servlet.http.HttpServletRequest request,
java.lang.String viewName,
java.lang.String controllerName,
org.springframework.web.servlet.ViewResolver viewResolver)
Resolves a view for the given view name and controller name
|
static GrailsWebRequest |
retrieveGrailsWebRequest()
Returns the GrailsWebRequest associated with the current request.
|
static void |
storeGrailsWebRequest(GrailsWebRequest webRequest)
Helper method to store the given GrailsWebRequest for the current
request.
|
static java.lang.String |
toQueryString(java.util.Map parameters)
Converts the given parameters to a query string using the default UTF-8 encoding
|
static java.lang.String |
toQueryString(java.util.Map params,
java.lang.String encoding)
Converts the given params into a query string started with ?
|
clearErrorRequestAttributes, exposeErrorRequestAttributes, exposeRequestAttributes, extractFilenameFromUrlPath, extractFullFilenameFromUrlPath, findParameterValue, findParameterValue, getCookie, getDefaultHtmlEscape, getNativeRequest, getNativeResponse, getOrCreateSessionAttribute, getParametersStartingWith, getRealPath, getRequiredSessionAttribute, getResponseEncodedHtmlEscape, getSessionAttribute, getSessionId, getSessionMutex, getTargetPage, getTempDir, hasSubmitParameter, isDefaultHtmlEscape, isIncludeRequest, isValidOrigin, parseMatrixVariables, removeWebAppRootSystemProperty, setSessionAttribute, setWebAppRootSystemPropertypublic static final char SLASH
public static final java.lang.String ENABLE_FILE_EXTENSIONS
public static final java.lang.String DISPATCH_ACTION_PARAMETER
public static final java.lang.String SEND_ALLOW_HEADER_FOR_INVALID_HTTP_METHOD
public static final java.lang.String LAYOUT_ATTRIBUTE
public static final java.lang.String RENDERING_VIEW
public static final java.lang.String GRAILS_DISPATCH_EXTENSION
public static final java.lang.String GRAILS_SERVLET_PATH
public static final java.lang.String EXCEPTION_ATTRIBUTE
public static org.springframework.web.servlet.ViewResolver lookupViewResolver(javax.servlet.ServletContext servletContext)
public static org.springframework.web.servlet.ViewResolver lookupViewResolver(org.springframework.context.ApplicationContext wac)
public static org.springframework.web.servlet.HandlerInterceptor[] lookupHandlerInterceptors(javax.servlet.ServletContext servletContext)
servletContext - The ServletContext instancepublic static org.springframework.web.context.request.WebRequestInterceptor[] lookupWebRequestInterceptors(javax.servlet.ServletContext servletContext)
servletContext - The ServletContext instancepublic static java.lang.String getRequestURIForGrailsDispatchURI(javax.servlet.http.HttpServletRequest request)
request - The requestpublic static org.codehaus.groovy.grails.commons.GrailsApplication lookupApplication(javax.servlet.ServletContext servletContext)
public static org.springframework.context.ApplicationContext findApplicationContext(javax.servlet.ServletContext servletContext)
servletContext - The servlet contextpublic static org.springframework.web.servlet.View resolveView(javax.servlet.http.HttpServletRequest request,
java.lang.String viewName,
java.lang.String controllerName,
org.springframework.web.servlet.ViewResolver viewResolver)
throws java.lang.Exception
request - The requestviewName - The view namecontrollerName - The controller nameviewResolver - The resolverjava.lang.Exception - Thrown if an error occurspublic static java.lang.String addViewPrefix(java.lang.String viewName)
public static java.lang.String addViewPrefix(java.lang.String viewName,
java.lang.String controllerName)
public static java.util.Map<java.lang.String,java.lang.Object> exposeRequestAttributesAndReturnOldValues(javax.servlet.http.HttpServletRequest request,
java.util.Map<java.lang.String,?> attributes)
public static void cleanupIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request,
java.util.Map<java.lang.String,java.lang.Object> toRestore)
public static void exposeIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request)
HttpServletRequest
attributes under the keys defined in the Servlet 2.4 specification,
for containers that implement 2.3 or an earlier version of the Servlet API:
javax.servlet.forward.request_uri,
javax.servlet.forward.context_path,
javax.servlet.forward.servlet_path,
javax.servlet.forward.path_info,
javax.servlet.forward.query_string.
Does not override values if already present, to not cause conflicts with the attributes exposed by Servlet 2.4+ containers themselves.
request - current servlet requestpublic static java.util.Map<java.lang.String,java.lang.Object> fromQueryString(java.lang.String queryString)
queryString - The query Stringpublic static java.lang.String toQueryString(java.util.Map params,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
params - The paramsencoding - The encoding to usejava.io.UnsupportedEncodingException - If the given encoding is not supportedpublic static java.lang.String toQueryString(java.util.Map parameters)
throws java.io.UnsupportedEncodingException
parameters - The parametersjava.io.UnsupportedEncodingException - If UTF-8 encoding is not supportedpublic static java.lang.String getFormatFromURI(java.lang.String uri)
null.uri - The URIpublic static java.lang.String getFormatFromURI(java.lang.String uri,
org.codehaus.groovy.grails.web.mime.MimeType[] mimeTypes)
null.uri - The URImimeTypes - The configured mime typespublic static boolean areFileExtensionsEnabled()
public static GrailsWebRequest retrieveGrailsWebRequest()
java.lang.IllegalStateException - if this is called outside of a
request.public static void storeGrailsWebRequest(GrailsWebRequest webRequest)
public static void clearGrailsWebRequest()
public static java.lang.String getForwardURI(javax.servlet.http.HttpServletRequest request)
request - The request