public class WebUtils extends org.springframework.web.utilWebUtils
Utility methods to access commons objects and perform common web related functions for the internal framework.
Modifiers | Name | Description |
---|---|---|
static java.lang.String |
ASYNC_REQUEST_URI_ATTRIBUTE |
|
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 |
Type Params | Return Type | Name and description |
---|---|---|
|
public 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 boolean |
areFileExtensionsEnabled() Returns the value of the "grails.mime.file.extensions" setting configured in application.groovy |
|
public static void |
cleanupIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request, java.util.Map<java.lang.String, java.lang.Object> toRestore) |
|
public static void |
clearGrailsWebRequest() Removes any GrailsWebRequest instance from the current request. |
|
public static void |
exposeIncludeRequestAttributes(javax.servlet.http.HttpServletRequest request) |
|
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 GrailsApplication |
findApplication(javax.servlet.ServletContext servletContext) Looks up the GrailsApplication instance |
|
public static org.springframework.context.ApplicationContext |
findApplicationContext(javax.servlet.ServletContext servletContext) Locates the ApplicationContext, returns null if not found |
|
public 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 |
|
public static java.lang.String |
getFormatFromURI(java.lang.String uri) Obtains the format from the URI. |
|
public static java.lang.String |
getFormatFromURI(java.lang.String uri, MimeType[] mimeTypes) Obtains the format from the URI. |
|
public 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. |
|
public static java.lang.String |
getRequestURIForGrailsDispatchURI(javax.servlet.http.HttpServletRequest request) The Grails dispatch servlet maps URIs like /app/grails/example/index.dispatch. |
|
public static boolean |
isAsync(javax.servlet.http.HttpServletRequest request) Check whether the given request is a forward request |
|
public static boolean |
isError(javax.servlet.http.HttpServletRequest request) Check whether the given request is a forward request |
|
public static boolean |
isForward(javax.servlet.http.HttpServletRequest request) Check whether the given request is a forward request |
|
public static boolean |
isForwardOrInclude(javax.servlet.http.HttpServletRequest request) Check whether the given request is an include or forward request |
|
public static boolean |
isInclude(javax.servlet.http.HttpServletRequest request) Check whether the given request is an include request |
|
public static GrailsApplication |
lookupApplication(javax.servlet.ServletContext servletContext) Looks up the GrailsApplication instance |
|
public static org.springframework.web.servlet.HandlerInterceptor[] |
lookupHandlerInterceptors(javax.servlet.ServletContext servletContext) Looks up all of the HandlerInterceptor instances registered for the application |
|
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) Looks up all of the WebRequestInterceptor instances registered with the application |
|
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) Resolves a view for the given view name and controller name |
|
public org.springframework.web.servlet.View |
resolveViewName(java.lang.String viewName, java.util.Locale locale) |
|
public static GrailsWebRequest |
retrieveGrailsWebRequest() Returns the GrailsWebRequest associated with the current request. |
|
public static void |
storeGrailsWebRequest(GrailsWebRequest webRequest) Helper method to store the given GrailsWebRequest for the current request. |
|
public static java.lang.String |
toQueryString(java.util.Map params, java.lang.String encoding) Converts the given params into a query string started with ? |
|
public static java.lang.String |
toQueryString(java.util.Map parameters) Converts the given parameters to a query string using the default UTF-8 encoding |
Returns the value of the "grails.mime.file.extensions" setting configured in application.groovy
Removes any GrailsWebRequest instance from the current request.
Looks up the GrailsApplication instance
Locates the ApplicationContext, returns null if not found
servletContext
- The servlet contextTakes a query string and returns the results as a map where the values are either a single entry or a list of values
queryString
- The query String Obtains the format from the URI. The format is the string following the . file extension in the last token of the URI.
If nothing comes after the ".", this method assumes that there is no format and returns null
.
uri
- The URI Obtains the format from the URI. The format is the string following the . file extension in the last token of the URI.
If nothing comes after the ".", this method assumes that there is no format and returns null
.
uri
- The URImimeTypes
- The configured mime typesObtains the forwardURI from the request, since Grails uses a forwarding technique for URL mappings. The actual request URI is held within a request attribute
request
- The requestThe Grails dispatch servlet maps URIs like /app/grails/example/index.dispatch. This method infers the controller URI for the dispatch URI so that /app/grails/example/index.dispatch becomes /app/example/index
request
- The requestCheck whether the given request is a forward request
request
- The requestCheck whether the given request is a forward request
request
- The requestCheck whether the given request is a forward request
request
- The requestCheck whether the given request is an include or forward request
request
- The requestCheck whether the given request is an include request
request
- The requestLooks up the GrailsApplication instance
Looks up all of the HandlerInterceptor instances registered for the application
servletContext
- The ServletContext instanceLooks up all of the WebRequestInterceptor instances registered with the application
servletContext
- The ServletContext instanceResolves a view for the given view name and controller name
request
- The requestviewName
- The view namecontrollerName
- The controller nameviewResolver
- The resolverReturns the GrailsWebRequest associated with the current request. This is the preferred means of accessing the GrailsWebRequest instance. If the exception is undesired, you can use RequestContextHolder.getRequestAttributes() instead.
Helper method to store the given GrailsWebRequest for the current request. Ensures consistency between RequestContextHolder and the relevant request attribute. This is the preferred means of updating the current web request.
Converts the given params into a query string started with ?
params
- The paramsencoding
- The encoding to useConverts the given parameters to a query string using the default UTF-8 encoding
parameters
- The parameters