Package com.aquima.web.util
Class UrlHelper
- java.lang.Object
-
- com.aquima.web.util.UrlHelper
-
public class UrlHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description UrlHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static String
fromContextPath(javax.servlet.http.HttpServletRequest request, String path)
static boolean
isAbsolute(String viewName)
-
-
-
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 tonoaccess.html
using this method will always returnredirect:/noaccess.html
and neverredirect:noaccess.html
which is equivalent toredirect:/start/noaccess.html
, regardless if the view name isnoaccess.html
or/noaccess.html
.- Parameters:
viewName
- the view name to redirect to (not null)
-
isAbsolute
public static boolean isAbsolute(String viewName)
-
-