Class UrlMappingUtils


  • public class UrlMappingUtils
    extends java.lang.Object
    Utility methods for working with UrlMappings
    Since:
    2.4
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildDispatchUrlForMapping​(UrlMappingInfo info)
      Constructs the URI to forward to using the given request and UrlMappingInfo instance
      static java.util.Map findAllParamsNotInKeys​(java.util.Map params, java.util.Set keys)  
      static java.util.Map findAllParamsNotInUrlMappingKeywords​(java.util.Map params)  
      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<java.lang.String,​java.lang.Object> model, boolean includeParams)
      Forwards a request for the given UrlMappingInfo object and model
      static org.grails.web.util.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 org.grails.web.util.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.grails.web.util.IncludedContent includeForUrlMappingInfo​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UrlMappingInfo info, java.util.Map model, LinkGenerator linkGenerator)
      Include whatever the given UrlMappingInfo maps to within the current response
      static UrlMappingsHolder lookupUrlMappings​(javax.servlet.ServletContext servletContext)
      Looks up the UrlMappingsHolder instance
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • findAllParamsNotInUrlMappingKeywords

        public static java.util.Map findAllParamsNotInUrlMappingKeywords​(java.util.Map params)
        Returns:
        a Map without entries whose key belongs to UrlMapping#KEYWORDS
      • findAllParamsNotInKeys

        public static java.util.Map findAllParamsNotInKeys​(java.util.Map params,
                                                           java.util.Set keys)
      • lookupUrlMappings

        public static UrlMappingsHolder lookupUrlMappings​(javax.servlet.ServletContext servletContext)
        Looks up the UrlMappingsHolder instance
        Parameters:
        servletContext - The ServletContext object
        Returns:
        The UrlMappingsHolder
      • resolveView

        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
        Resolves a view for the given view and UrlMappingInfo instance
        Parameters:
        request - The request
        info - The info
        viewName - The view name
        viewResolver - The view resolver
        Returns:
        The view or null
        Throws:
        java.lang.Exception
      • buildDispatchUrlForMapping

        public static java.lang.String buildDispatchUrlForMapping​(UrlMappingInfo info)
        Constructs the URI to forward to using the given request and UrlMappingInfo instance
        Parameters:
        info - The UrlMappingInfo
        Returns:
        The URI to forward to
      • forwardRequestForUrlMappingInfo

        public static java.lang.String forwardRequestForUrlMappingInfo​(javax.servlet.http.HttpServletRequest request,
                                                                       javax.servlet.http.HttpServletResponse response,
                                                                       UrlMappingInfo info,
                                                                       java.util.Map<java.lang.String,​java.lang.Object> model,
                                                                       boolean includeParams)
                                                                throws javax.servlet.ServletException,
                                                                       java.io.IOException
        Forwards a request for the given UrlMappingInfo object and model
        Parameters:
        request - The request
        response - The response
        info - The UrlMappingInfo object
        model - The Model
        includeParams - Whether to include any request parameters
        Returns:
        The URI forwarded too
        Throws:
        javax.servlet.ServletException - Thrown when an error occurs executing the forward
        java.io.IOException - Thrown when an error occurs executing the forward
      • includeForUrlMappingInfo

        public static org.grails.web.util.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
        Parameters:
        request - The request
        response - The response
        info - The UrlMappingInfo
        model - The model
        Returns:
        The included content
      • includeForUrlMappingInfo

        public static org.grails.web.util.IncludedContent includeForUrlMappingInfo​(javax.servlet.http.HttpServletRequest request,
                                                                                   javax.servlet.http.HttpServletResponse response,
                                                                                   UrlMappingInfo info,
                                                                                   java.util.Map model,
                                                                                   LinkGenerator linkGenerator)
        Include whatever the given UrlMappingInfo maps to within the current response
        Parameters:
        request - The request
        response - The response
        info - The UrlMappingInfo
        model - The model
        linkGenerator - allows for reverse url mapping
        Returns:
        The included content
      • includeForUrl

        public static org.grails.web.util.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
        Parameters:
        includeUrl - The URL to include
        request - The request
        response - The response
        model - The model
        Returns:
        The content