首页 > 解决方案 > 从 Web 服务中注销 JPA

问题描述

我在 springboot 上创建 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>

它不可点击。

标签: javaspring-bootweb-servicesjpa

解决方案


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

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

推荐阅读