[OmniFaces utilities] The
getRequestURI()
method returns the HTTP request URI, regardless of any forward or error dispatch. This is the part after the domain in the request URL, including the leading slash.Method:
Use this one in JSF context (Faces#getRequestURI()) See also: Faces.getRequest() | Faces.getContext() | Use this one outside JSF context (Servlets#getRequestURI()) See also: Utils.coalesce() |
|
Some use cases are available right in OmniFaces source code. For example, OmniFaces uses getRequestURI() to check if the given HTTP servlet request is a JSF resource request:
public static
boolean isFacesResourceRequest(HttpServletRequest request) {
return getRequestURI(request).startsWith(request.getContextPath()
+ ResourceHandler.RESOURCE_IDENTIFIER + "/");
}
public static
String getRequestURIWithQueryString(HttpServletRequest request) {
String requestURI = getRequestURI(request);
String queryString =
getRequestQueryString(request);
return (queryString == null) ? requestURI :
(requestURI + "?" + queryString);
}
Niciun comentariu :
Trimiteți un comentariu