问题
I need something that will uniquely identify my JSF (XHTML) page.
I know that I have:
String URI = servletRequest.getRequestURI();
This gives my full path, but that doesn't help if I use PrettyFaces or any other URL changing library.
回答1:
You can use UIViewRoot#getViewId() for this:
String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
It's also available in EL as follows:
#{view.viewId}
来源:https://stackoverflow.com/questions/12371100/identifying-path-of-current-jsf-xhtml-page