You normally want to use UIViewRoot#getViewId()
for this.
String viewId = facesContext.getViewRoot().getViewId();
This is in EL also available as follows:
#{view.viewId}
Exactly this value is reuseable in navigation case outcomes such as <h:link outcome>
and <h:button outcome>
.
Alternatively, you can also use HttpServletRequest#getRequestURI()
to get whatever the enduser is actually seeing in the browser address bar.
String uri = ((HttpServletRequest) externalContext.getRequest()).getRequestURI();
Which is in EL also available as follows:
#{request.requestURI}
Exactly this value is reuseable in <h:outputLink value>
or plain <a href>
. Note that you can't use it as navigation case outcome.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…