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 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, 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 boolean |
areFileExtensionsEnabled()
Returns the value of the "grails.mime.file.extensions" setting configured in COnfig.groovy
|
static java.lang.String |
buildDispatchUrlForMapping(UrlMappingInfo info)
Constructs the URI to forward to using the given request and UrlMappingInfo instance
|
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.lang.String |
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info) |
static java.lang.String |
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info,
java.util.Map model) |
static java.lang.String |
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info,
java.util.Map model,
boolean includeParams)
Forwards a request for the given UrlMappingInfo object and model
|
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 org.codehaus.groovy.grails.commons.GrailsClass |
getConfiguredControllerForUrlMappingInfo(GrailsWebRequest webRequest,
UrlMappingInfo info,
grails.web.UrlConverter urlConverterToUse,
org.codehaus.groovy.grails.commons.GrailsApplication grailsApplicationToUse) |
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 IncludedContent |
includeForUrl(java.lang.String includeUrl,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.Map model)
Includes the given URL returning the resulting content as a String
|
static IncludedContent |
includeForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info,
java.util.Map model)
Include whatever the given UrlMappingInfo maps to within the current response
|
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 UrlMappingsHolder |
lookupUrlMappings(javax.servlet.ServletContext servletContext)
Looks up the UrlMappingsHolder instance
|
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 org.springframework.web.servlet.View |
resolveView(javax.servlet.http.HttpServletRequest request,
UrlMappingInfo info,
java.lang.String viewName,
org.springframework.web.servlet.ViewResolver viewResolver)
Resolves a view for the given view and UrlMappingInfo instance
|
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, exposeForwardRequestAttributes, exposeRequestAttributes, extractFilenameFromUrlPath, extractFullFilenameFromUrlPath, findParameterValue, findParameterValue, getCookie, getDefaultHtmlEscape, getNativeRequest, getNativeResponse, getOrCreateSessionAttribute, getParametersStartingWith, getRealPath, getRequiredSessionAttribute, getSessionAttribute, getSessionId, getSessionMutex, getTargetPage, getTempDir, hasSubmitParameter, isDefaultHtmlEscape, isIncludeRequest, 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 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 UrlMappingsHolder lookupUrlMappings(javax.servlet.ServletContext servletContext)
servletContext - The ServletContext objectpublic 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.web.servlet.View resolveView(javax.servlet.http.HttpServletRequest request,
UrlMappingInfo info,
java.lang.String viewName,
org.springframework.web.servlet.ViewResolver viewResolver)
throws java.lang.Exception
request - The requestinfo - The infoviewName - The view nameviewResolver - The view resolverjava.lang.Exceptionpublic 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 buildDispatchUrlForMapping(UrlMappingInfo info)
info - The UrlMappingInfopublic static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info)
throws javax.servlet.ServletException,
java.io.IOException
javax.servlet.ServletExceptionjava.io.IOExceptionforwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map)public static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info,
java.util.Map model)
throws javax.servlet.ServletException,
java.io.IOException
javax.servlet.ServletExceptionjava.io.IOExceptionforwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map, boolean)public static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
UrlMappingInfo info,
java.util.Map model,
boolean includeParams)
throws javax.servlet.ServletException,
java.io.IOException
request - The requestresponse - The responseinfo - The UrlMappingInfo objectmodel - The ModelincludeParams - Whether to include any request parametersjavax.servlet.ServletException - Thrown when an error occurs executing the forwardjava.io.IOException - Thrown when an error occurs executing the forwardpublic static IncludedContent includeForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info, java.util.Map model)
request - The requestresponse - The responseinfo - The UrlMappingInfomodel - The modelpublic static IncludedContent includeForUrl(java.lang.String includeUrl, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map model)
includeUrl - The URL to includerequest - The requestresponse - The responsemodel - The modelpublic 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 requestpublic static org.codehaus.groovy.grails.commons.GrailsClass getConfiguredControllerForUrlMappingInfo(GrailsWebRequest webRequest, UrlMappingInfo info, grails.web.UrlConverter urlConverterToUse, org.codehaus.groovy.grails.commons.GrailsApplication grailsApplicationToUse)