简体   繁体   中英

How to Logout in a JSF application

I have to use my Company login resource and, how can I set the logout servlet into my primefaces component?

How "translate" this...

//in a jsp page:
<a href="<%=request.getContextPath()%>/servlet/com.app.ServletEndSession?initialPage=/index.jsp" > Logout </a>

...into this:

<p:commandButton type="button" value="Logout" action="??" />

Thanks in advance.

您的<a/>应该成为

<p:button href="#{facesContext.externalContext.requestContextPath}/servlet/com.app.ServletEndSession?initialPage=/index.jsp" value="Dialogit"/>

You could just use a managed bean on the commandButton and then do a redirect in your page? As you definitely want to navigate away with p:commandbutton youw would want to set ajax="false" put action .

Alternatively you could just use

<p:commandButton type="button" value="logout" onclick="javascriptTolinkToServletEndEsssion" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM