1
我使用PrettyFaces作爲URL重寫庫如下:獲取當前頁面的名稱與JSF/PrettyFaces
@URLMappings(mappings = {
@URLMapping(id = "page1", pattern = "/page1", viewId = "/faces/pages/page1.xhtml"),
@URLMapping(id = "page2", pattern = "/page2", viewId = "/faces/pages/page2.xhtml") })
我可以得到viewId如下:
String viewId = facesContext.getViewRoot().getViewId();
這將返回類似: /faces/pages/page1.xhtml
我想知道是否有直接的方式來獲取模式或視圖的ID返回像page1或我必須使用子串上述代碼獲取viewId?
是有可能得到的XHTML頁面映射的id? –
yes:#{prettyContext.currentInstance.currentMapping()。id()} – Lincoln