0

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?

Newbie
  • 1,584
  • 9
  • 33
  • 72
  • Create a real simple plain had webapp without any spring in it. Does it work then? Read about https://stackoverflow.com/questions/30683584/what-url-to-use-to-link-navigate-to-other-jsf-pages. The outcome should never contain the context path... Wrong assumption and maybe even a wrong tutorial you used. – Kukeltje May 18 '18 at 06:30
  • @Kukeltje I have updated my question. – Newbie May 18 '18 at 07:57
  • read my comment – Kukeltje May 18 '18 at 07:57
  • @Kukeltje sorry I am not really understand "Create a real simple plain had webapp without any spring in it", could you please explain a bit? sorry for my bad English – Newbie May 18 '18 at 08:03
  • So you stopped reading after that? There was more: _"The outcome should never contain the context path"_ – Kukeltje May 18 '18 at 08:05
  • @Kukeltje the outcome is correct, which is `myProject/logout`, and if I copy paste the link run it, I can logout. – Newbie May 18 '18 at 08:08
  • No the outcome should be just logout it is NOT a url – Kukeltje May 18 '18 at 09:10
  • https://stackoverflow.com/questions/6469298/difference-between-hlink-and-houtputlink – Kukeltje May 18 '18 at 12:32

0 Answers0