导航到不同文件夹中的页面

时间:2016-03-31 19:53:08

标签: jsf jsf-2.2

我使用这个html代码导航到JSF页面:

<a href="NewCustomer.xhtml">New Customer</a>

这个JSF代码工作正常

<h:outputLink value="NewCustomer.xhtml" >
    New Customer
</h:outputLink>

但是当我在不同文件夹中有页面时,这不起作用。

如何在不同文件夹中的页面之间导航?

点击链接后我得到了这个结果:

http://localhost:8085/Crm_site/Dashboard.xhtml

我在这里航行:

http://localhost:8085/customers/Customers.xhtml

但它应该在这里

http://localhost:8085/Crm_site/customers/Customers.xhtml

1 个答案:

答案 0 :(得分:1)

在页面名称

之前添加您的上下文路径
#{request.contextPath}/customers/Customers.xhtml

或者您可以使用外部上下文从支持bean导航

 FacesContext.getCurrentInstance().getExternalContext().redirect(url)
相关问题