|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.util.WebUtils org.codehaus.groovy.grails.web.util.WebUtils
public class WebUtils extends org.springframework.web.util.WebUtils
Utility methods to access commons objects and perform common web related functions for the internal framework.
Field Summary | |
---|---|
static java.lang.String |
DISPATCH_ACTION_PARAMETER
|
static java.lang.String |
ENABLE_FILE_EXTENSIONS
|
static char |
SLASH
|
Fields inherited from class org.springframework.web.util.WebUtils | |
---|---|
INCLUDE_REQUEST_URI_ATTRIBUTE, INCLUDE_CONTEXT_PATH_ATTRIBUTE, INCLUDE_SERVLET_PATH_ATTRIBUTE, INCLUDE_PATH_INFO_ATTRIBUTE, INCLUDE_QUERY_STRING_ATTRIBUTE, FORWARD_REQUEST_URI_ATTRIBUTE, FORWARD_CONTEXT_PATH_ATTRIBUTE, FORWARD_SERVLET_PATH_ATTRIBUTE, FORWARD_PATH_INFO_ATTRIBUTE, FORWARD_QUERY_STRING_ATTRIBUTE, ERROR_STATUS_CODE_ATTRIBUTE, ERROR_EXCEPTION_TYPE_ATTRIBUTE, ERROR_MESSAGE_ATTRIBUTE, ERROR_EXCEPTION_ATTRIBUTE, ERROR_REQUEST_URI_ATTRIBUTE, ERROR_SERVLET_NAME_ATTRIBUTE, CONTENT_TYPE_CHARSET_PREFIX, DEFAULT_CHARACTER_ENCODING, TEMP_DIR_CONTEXT_ATTRIBUTE, HTML_ESCAPE_CONTEXT_PARAM, WEB_APP_ROOT_KEY_PARAM, DEFAULT_WEB_APP_ROOT_KEY, SUBMIT_IMAGE_SUFFIXES, SESSION_MUTEX_ATTRIBUTE |
Method Summary | |
---|---|
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()
|
static void
|
exposeIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request)
Expose the current request URI and paths as javax.servlet.http.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:
|
static java.lang.String
|
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info)
@see org.codehaus.groovy.grails.web.util.WebUtils#forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map) |
static java.lang.String
|
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info, java.util.Map model)
@see #forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map, boolean) |
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
|
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, MimeType[] mimeTypes)
|
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 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(javax.servlet.ServletContext servletContext)
|
static org.springframework.web.servlet.ViewResolver
|
lookupViewResolver(org.springframework.context.ApplicationContext wac)
|
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, UrlMappingInfo info, java.lang.String viewName, org.springframework.web.servlet.ViewResolver viewResolver)
Resolves a view for the given view and UrlMappingInfo instance |
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)
|
static java.lang.String
|
toQueryString(java.util.Map params, java.lang.String encoding)
Converts the given params into a query string started with ? |
static java.lang.String
|
toQueryString(java.util.Map parameters)
Converts the given parameters to a query string using the default UTF-8 encoding |
Methods inherited from class org.springframework.web.util.WebUtils | |
---|---|
org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext), org.springframework.web.util.WebUtils#getSessionId(javax.servlet.http.HttpServletRequest), org.springframework.web.util.WebUtils#getDefaultHtmlEscape(javax.servlet.ServletContext), org.springframework.web.util.WebUtils#isDefaultHtmlEscape(javax.servlet.ServletContext), org.springframework.web.util.WebUtils#getRealPath(javax.servlet.ServletContext, java.lang.String), org.springframework.web.util.WebUtils#getSessionMutex(javax.servlet.http.HttpSession), org.springframework.web.util.WebUtils#getNativeRequest(javax.servlet.ServletRequest, java.lang.Class), org.springframework.web.util.WebUtils#getParametersStartingWith(javax.servlet.ServletRequest, java.lang.String), org.springframework.web.util.WebUtils#getCookie(javax.servlet.http.HttpServletRequest, java.lang.String), org.springframework.web.util.WebUtils#exposeForwardRequestAttributes(javax.servlet.http.HttpServletRequest), org.springframework.web.util.WebUtils#isIncludeRequest(javax.servlet.ServletRequest), org.springframework.web.util.WebUtils#clearErrorRequestAttributes(javax.servlet.http.HttpServletRequest), org.springframework.web.util.WebUtils#exposeErrorRequestAttributes(javax.servlet.http.HttpServletRequest, java.lang.Throwable, java.lang.String), org.springframework.web.util.WebUtils#getNativeResponse(javax.servlet.ServletResponse, java.lang.Class), org.springframework.web.util.WebUtils#setWebAppRootSystemProperty(javax.servlet.ServletContext), org.springframework.web.util.WebUtils#removeWebAppRootSystemProperty(javax.servlet.ServletContext), org.springframework.web.util.WebUtils#getSessionAttribute(javax.servlet.http.HttpServletRequest, java.lang.String), org.springframework.web.util.WebUtils#getRequiredSessionAttribute(javax.servlet.http.HttpServletRequest, java.lang.String), org.springframework.web.util.WebUtils#setSessionAttribute(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.Object), org.springframework.web.util.WebUtils#getOrCreateSessionAttribute(javax.servlet.http.HttpSession, java.lang.String, java.lang.Class), org.springframework.web.util.WebUtils#exposeRequestAttributes(javax.servlet.ServletRequest, java.util.Map), org.springframework.web.util.WebUtils#hasSubmitParameter(javax.servlet.ServletRequest, java.lang.String), org.springframework.web.util.WebUtils#findParameterValue(java.util.Map, java.lang.String), org.springframework.web.util.WebUtils#findParameterValue(javax.servlet.ServletRequest, java.lang.String), org.springframework.web.util.WebUtils#getTargetPage(javax.servlet.ServletRequest, java.lang.String, int), org.springframework.web.util.WebUtils#extractFilenameFromUrlPath(java.lang.String), org.springframework.web.util.WebUtils#extractFullFilenameFromUrlPath(java.lang.String), org.springframework.web.util.WebUtils#wait(), org.springframework.web.util.WebUtils#wait(long), org.springframework.web.util.WebUtils#wait(long, int), org.springframework.web.util.WebUtils#equals(java.lang.Object), org.springframework.web.util.WebUtils#toString(), org.springframework.web.util.WebUtils#hashCode(), org.springframework.web.util.WebUtils#getClass(), org.springframework.web.util.WebUtils#notify(), org.springframework.web.util.WebUtils#notifyAll() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final java.lang.String DISPATCH_ACTION_PARAMETER
public static final java.lang.String ENABLE_FILE_EXTENSIONS
public static final char SLASH
Method Detail |
---|
/** public static boolean areFileExtensionsEnabled()
public static java.lang.String buildDispatchUrlForMapping(UrlMappingInfo info)
info
- The UrlMappingInfo
public static void clearGrailsWebRequest()
public static void exposeIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request)
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 request
public static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info)
@SuppressWarnings("rawtypes") public static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info, java.util.Map model)
@SuppressWarnings({ "unchecked", "rawtypes" }) public static java.lang.String forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info, java.util.Map model, boolean includeParams)
request
- The requestresponse
- The responseinfo
- The UrlMappingInfo objectmodel
- The ModelincludeParams
- Whether to include any request parameters
String[] pairs = queryString.split("&"); public static java.util.Map fromQueryString(java.lang.String queryString)
queryString
- The query String
public static java.lang.String getFormatFromURI(java.lang.String uri)
null
.
uri
- The URI
public static java.lang.String getFormatFromURI(java.lang.String uri, MimeType[] mimeTypes)
public static java.lang.String getForwardURI(javax.servlet.http.HttpServletRequest request)
request
- The request
public static java.lang.String getRequestURIForGrailsDispatchURI(javax.servlet.http.HttpServletRequest request)
request
- The request
response = wrapped != null ? wrapped : response; public 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 model
final GrailsWebRequest webRequest = GrailsWebRequest.lookup(request); public 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 model
public static GrailsApplication lookupApplication(javax.servlet.ServletContext servletContext)
public static org.springframework.web.servlet.HandlerInterceptor[] lookupHandlerInterceptors(javax.servlet.ServletContext servletContext)
servletContext
- The ServletContext instance
public static UrlMappingsHolder lookupUrlMappings(javax.servlet.ServletContext servletContext)
servletContext
- The ServletContext object
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.context.request.WebRequestInterceptor[] lookupWebRequestInterceptors(javax.servlet.ServletContext servletContext)
servletContext
- The ServletContext instance
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)
request
- The requestinfo
- The infoviewName
- The view nameviewResolver
- The view resolver
public 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)
request
- The requestviewName
- The view namecontrollerName
- The controller nameviewResolver
- The resolver
public static GrailsWebRequest retrieveGrailsWebRequest()
public static void storeGrailsWebRequest(GrailsWebRequest webRequest)
Map.Entry entry = (Map.Entry) i.next(); public static java.lang.String toQueryString(java.util.Map params, java.lang.String encoding)
params
- The paramsencoding
- The encoding to use
private static boolean appendEntry(Map.Entry entry, StringBuilder queryString, String encoding, String path) throws UnsupportedEncodingException { public static java.lang.String toQueryString(java.util.Map parameters)
parameters
- The parameters
Groovy Documentation