使用这个答案我试图注销。
小服务程序代码:
@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'
我不认为 servlet 正在使用“/logout” url 模式接收请求。我做错了什么?