Class UrlHelper


  • public class UrlHelper
    extends Object
    • Constructor Detail

      • UrlHelper

        public UrlHelper()
    • Method Detail

      • fromContextPath

        public static String fromContextPath​(javax.servlet.http.HttpServletRequest request,
                                             String path)
      • absoluteRedirect

        public static String absoluteRedirect​(String viewName)
        Returns a "redirect:"-prefixed view name with a leading slash to indicate we want to redirect to a view relative to the context path.

        This method helps perform the redirection relative to the context path in a uniform manner when some view names already include a leading slash and others don't. It ensures that the redirection is always relative to the context path and not to the current servlet path. (eg. if the current servlet path is /start/shortcutName , then redirecting to noaccess.html using this method will always return redirect:/noaccess.html and never redirect:noaccess.html which is equivalent to redirect:/start/noaccess.html, regardless if the view name is noaccess.html or /noaccess.html.

        Parameters:
        viewName - the view name to redirect to (not null)
      • isAbsolute

        public static boolean isAbsolute​(String viewName)