0
使用this解决方法我尝试登出。使用servlet在Java EE应用程序中登录用户
servlet代码:
@WebServlet(name = "LogoutServlet", urlPatterns = {"/logout"})
public class LogoutServlet extends HttpServlet {
private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(user.class);
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Destroys the session for this user.
if (request.getSession(false) != null) {
request.getSession(false).invalidate();
}
// Redirects back to the initial page.
logger.warn(request.getContextPath());
response.sendRedirect(request.getContextPath());
}
}
查看代码:
<h:form>
<h:commandButton value="Logout" action="/logout"/>
</h:form>
错误:
Unable to find matching navigation case with from-view-id '/Admin/appManager.xhtml' for action '/logout' with outcome '/logout'
我不认为servle t以“/ logout”url模式接受请求。我做了什么不正确?
在所有页面中使用具有注销方法的单个支持bean是否公平?我可能有很多页面,并且每个页面调用相同的后备Bean方法 – kinkajou 2012-07-24 06:03:21
是的。在任何页面中,您都可以使用多个支持bean;无论是数据还是行动。相反,您可以使用任何页面上的任何bean。 – SJuan76 2012-07-24 06:05:25
+1 helpful :)你可以用标签和servlet提供简单的例子吗? – kinkajou 2012-07-24 06:10:44