I have a very simple logout link
<h:link value="Logout" outcome="#{request.contextPath}/logout" styleClass="nav-link" />
It gives me error This link is disabled because a navigation case could not be matched.
But if I use a form to logout like below, it works:
<h:form onsubmit="this.action='#{request.contextPath}/logout';">
<p:commandButton value="Logout" ajax="false" />
</h:form>
This is how I config security for logout:
http.logout().logoutUrl("/logout").logoutSuccessUrl("/").invalidateHttpSession(true);
May I know where is the problem?
UPDATE
Even if I hard code the full path, the error still there.
I have a link contextPath/login
, which point to login.xhtml
, if I remove the login.xhtml
from my project directory, it will come out the same error message. Therefore I suspect the problem is because JSF could not find any file named logout
in my project directory. Any idea on how to solve this problem?
UPDATE 2
I found that if I use h:outputLink
then the problem will be solved, but instead of force to use h:outputLink
, I want to know the actual cause of the problem. Is it because h:link
is bound to the JSF navigation rule? Is there a way to solve this problem? or I have to use alternative, like h:outputlink
?