[OmniFaces utilities] The
getMapping()
method determines and returns the faces servlet mapping used in the current request. If JSF is prefix mapped (e.g. /faces/*
), then this returns the whole path, with a leading slash (e.g. /faces
). If JSF is suffix mapped (e.g. *.xhtml
), then this returns the whole extension (e.g. .xhtml
).[OmniFaces utilities] The
isPrefixMapping()
method returns whether the faces servlet mapping used in the current request is a prefix mapping.Method:
For JSF, the
faces servlet mapping is specified in web.xml file as below (several common
cases):
·
without prefix mapping (with suffix
mapping, *.xhtml)
<servlet-mapping>
<servlet-name>Faces
Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
·
common prefix mapping (e.g. /faces/*).
<servlet-mapping>
<servlet-name>Faces
Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
·
un-common prefix mapping (e.g. /797b/*).
<servlet-mapping>
<servlet-name>Faces
Servlet</servlet-name>
<url-pattern>/797b/*</url-pattern>
</servlet-mapping>
Usage:
import org.omnifaces.util.Faces;
Usage:
import org.omnifaces.util.Faces;
...
String
mapping = Faces.getMapping(); //e.g. prefixes: /faces, /797b
suffixes: .xhtml
or,
import
static org.omnifaces.util.Faces.getMapping;
...
String
mapping = getMapping(); //e.g. prefixes: /faces, /797b
suffixes: .xhtml
OmniFaces
also comes with an OmniFaces utilities that returns true if the faces servlet mapping
used in the current request is a prefix mapping. This OmniFaces utilities is named, isPrefixMapping():
Method:
import
org.omnifaces.util.Faces;
...
// e.g. for '/faces', '/797b' it returns true, while for '.xhtml' suffix, it will return false
boolean
isprefix = Faces.isPrefixMapping();
or,
// e.g. for '/faces', '/797b' it returns true, while for '.xhtml' suffix, it will return false
import
static org.omnifaces.util.Faces.isPrefixMapping;
...
boolean
isprefix = Faces.isPrefixMapping();
Niciun comentariu :
Trimiteți un comentariu