JPA 从 Web 服务注销

JPA logout from web service

我在 spring boot 上创建 Web 服务并使用 JPA。我想在我的页面上添加注销按钮,但它不起作用。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Hello</title>
</head>
<body>
<c:if test="${pageContext.request.userPrincipal.name !=null }">
    <form method="post" id="LogoutForm" action="${path}/logout">
        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
    </form>
    <p>Welcome ${pageContext.request.userPrincipal.name} | <a onclick="document.forms['logoutForm'].submit()">Logout</a></p>
    <h1>${message}</h1>
    <p><a href="${path}/user/list">User list</a></p>
    <p><a href="${path}/user/form">Add User</a></p>
    <p><a href="${path}/address/list">Address list</a></p>
    <p><a href="${path}/address/form">Add Address</a></p>
</c:if>
</body>
</html>

无法点击。

你必须像这样添加一个 href:

<a href="#" onclick="document.forms['logoutForm'].submit()">Logout</a>