|
||||||||||
PREV CLASS NEXT CLASS | 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
Utility methods to access commons objects and perform common web related functions for the internal framework
Field Summary | |
---|---|
static String |
DISPATCH_ACTION_PARAMETER
|
static String |
ENABLE_FILE_EXTENSIONS
|
static char |
SLASH
|
Constructor Summary | |
---|---|
WebUtils()
|
Method Summary | |
---|---|
static boolean |
areFileExtensionsEnabled()
Returns the value of the "grails.mime.file.extensions" setting configured in COnfig.groovy |
static 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 String |
forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response,
UrlMappingInfo info)
|
static String |
forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response,
UrlMappingInfo info,
Map model)
|
static String |
forwardRequestForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response,
UrlMappingInfo info,
Map model,
boolean includeParams)
Forwards a request for the given UrlMappingInfo object and model |
static String |
getFormatFromURI(String uri)
Obtains the format from the URI. |
static String |
getForwardURI(HttpServletRequest request)
Obtains the forwardURI from the request, since Grails uses a forwarding technique for URL mappings. |
static String |
getRequestURIForGrailsDispatchURI(HttpServletRequest request)
The Grails dispatch servlet maps URIs like /app/grails/example/index.dispatch. |
static IncludedContent |
includeForUrl(String includeUrl,
HttpServletRequest request,
HttpServletResponse response,
Map model)
Includes the given URL returning the resulting content as a String |
static IncludedContent |
includeForUrlMappingInfo(HttpServletRequest request,
HttpServletResponse response,
UrlMappingInfo info,
Map model)
Include whatever the given UrlMappingInfo maps to within the current response |
static GrailsApplication |
lookupApplication(ServletContext servletContext)
Looks up the GrailsApplication instance |
static HandlerInterceptor[] |
lookupHandlerInterceptors(ServletContext servletContext)
Looks up all of the HandlerInterceptor instances registered for the application |
static UrlMappingsHolder |
lookupUrlMappings(ServletContext servletContext)
Looks up the UrlMappingsHolder instance |
static ViewResolver |
lookupViewResolver(ServletContext servletContext)
|
static WebRequestInterceptor[] |
lookupWebRequestInterceptors(ServletContext servletContext)
Looks up all of the WebRequestInterceptor instances registered with the application |
static View |
resolveView(HttpServletRequest request,
String viewName,
String controllerName,
ViewResolver viewResolver)
Resolves a view for the given view name and controller name |
static View |
resolveView(HttpServletRequest request,
UrlMappingInfo info,
String viewName,
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 String |
toQueryString(Map parameters)
Converts the given parameters to a query string using the default UTF-8 encoding |
static String |
toQueryString(Map params,
String encoding)
Converts the given params into a query string started with ? |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char SLASH
public static final String ENABLE_FILE_EXTENSIONS
public static final String DISPATCH_ACTION_PARAMETER
Constructor Detail |
---|
public WebUtils()
Method Detail |
---|
public static ViewResolver lookupViewResolver(ServletContext servletContext)
public static HandlerInterceptor[] lookupHandlerInterceptors(ServletContext servletContext)
servletContext
- The ServletContext instance
public static WebRequestInterceptor[] lookupWebRequestInterceptors(ServletContext servletContext)
servletContext
- The ServletContext instance
public static UrlMappingsHolder lookupUrlMappings(ServletContext servletContext)
servletContext
- The ServletContext object
public static String getRequestURIForGrailsDispatchURI(HttpServletRequest request)
request
- The requestpublic static GrailsApplication lookupApplication(ServletContext servletContext)
public static View resolveView(HttpServletRequest request, UrlMappingInfo info, String viewName, ViewResolver viewResolver) throws Exception
request
- The requestinfo
- The infoviewName
- The view nameviewResolver
- The view resolver
Exception
public static View resolveView(HttpServletRequest request, String viewName, String controllerName, ViewResolver viewResolver) throws Exception
request
- The requestviewName
- The view namecontrollerName
- The controller nameviewResolver
- The resolver
Exception
- Thrown if an error occurspublic static String buildDispatchUrlForMapping(UrlMappingInfo info)
info
- The UrlMappingInfo
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request, HttpServletResponse response, UrlMappingInfo info) throws ServletException, IOException
ServletException
IOException
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map)
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request, HttpServletResponse response, UrlMappingInfo info, Map model) throws ServletException, IOException
ServletException
IOException
forwardRequestForUrlMappingInfo(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.codehaus.groovy.grails.web.mapping.UrlMappingInfo, java.util.Map, boolean)
public static String forwardRequestForUrlMappingInfo(HttpServletRequest request, HttpServletResponse response, UrlMappingInfo info, Map model, boolean includeParams) throws ServletException, IOException
request
- The requestresponse
- The responseinfo
- The UrlMappingInfo objectmodel
- The ModelincludeParams
- Whether to include any request parameters
ServletException
- Thrown when an error occurs executing the forward
IOException
- Thrown when an error occurs executing the forwardpublic static IncludedContent includeForUrlMappingInfo(HttpServletRequest request, HttpServletResponse response, UrlMappingInfo info, Map model)
request
- The requestresponse
- The responseinfo
- The UrlMappingInfomodel
- The model
public static IncludedContent includeForUrl(String includeUrl, HttpServletRequest request, HttpServletResponse response, Map model)
includeUrl
- The URL to includerequest
- The requestresponse
- The responsemodel
- The model
public static String toQueryString(Map params, String encoding) throws UnsupportedEncodingException
params
- The paramsencoding
- The encoding to use
UnsupportedEncodingException
- If the given encoding is not supportedpublic static String toQueryString(Map parameters) throws UnsupportedEncodingException
parameters
- The parameters
UnsupportedEncodingException
- If UTF-8 encoding is not supportedpublic static String getFormatFromURI(String uri)
null
.
uri
- The URI
public static boolean areFileExtensionsEnabled()
public static GrailsWebRequest retrieveGrailsWebRequest()
IllegalStateException
- if this is called outside of a
request.public static void storeGrailsWebRequest(GrailsWebRequest webRequest)
public static void clearGrailsWebRequest()
public static String getForwardURI(HttpServletRequest request)
request
- The request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |