Mah*_*leh 2 java url-rewriting jsf-2 prettyfaces
我正在使用PrettyFaces作为url重写库,如下所示:
@URLMappings(mappings = {
@URLMapping(id = "page1", pattern = "/page1", viewId = "/faces/pages/page1.xhtml"),
@URLMapping(id = "page2", pattern = "/page2", viewId = "/faces/pages/page2.xhtml") })
Run Code Online (Sandbox Code Playgroud)
我可以得到viewId如下:
String viewId = facesContext.getViewRoot().getViewId();
Run Code Online (Sandbox Code Playgroud)
这将返回如下内容:/faces/pages/page1.xhtml
我想知道是否有一种直接的方法来获取视图的模式或id以返回类似page1的东西,或者我必须在上面的代码中使用substring来获取viewId?
是的:)只需致电:
PrettyContext.getCurrentInstance().getCurrentMapping().getId();
Run Code Online (Sandbox Code Playgroud)
或者,.getPattern()或等...
干杯:)
| 归档时间: |
|
| 查看次数: |
5169 次 |
| 最近记录: |