Spring boot Spring Boot Delete函数无法识别变量?

Spring boot Spring Boot Delete函数无法识别变量?,spring-boot,spring-data,Spring Boot,Spring Data,我的删除功能有一个小错误。出于某种原因,它没有将“代码”输入我的控制器。不知道为什么 这是我的jsp页面 <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%

我的删除功能有一个小错误。出于某种原因,它没有将“代码”输入我的控制器。不知道为什么

这是我的jsp页面

<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  %>  
<%@ page contentType="text/html; charset=UTF-8" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>All Products</title>
    </head> 
    <body>
        <security:authorize access="hasRole('SUPERADMIN')"><p>Welcome ${uname}, <a href="/logout">Logout</a></p></security:authorize>
        <security:authorize access="hasRole('ADMIN')"><p>Welcome ${uname},<a href="/logout">Logout</a></p></security:authorize>
        <security:authorize access="hasRole('USER')"><p>Welcome ${uname},<a href="/logout">Logout</a></p></security:authorize>
        <table style="width:100%">
            <tr>
                <th align="left">Code</th>
                <th align="left">Name</th>
                <th align="left">Description</th>
                <th align="left">Buy Price</th>
                <th align="left">Sell Price</th>
                <th align="left">Qty In Stock</th>
                <th align="left">Actions</th>
            </tr>
            <c:forEach items="${productList}" var="product"> 
                <tr>
                    <td>${product.code}</td>
                    <td>${product.name}</td>
                    <td>${product.description}</td>
                    <td><fmt:setLocale value="en_EUR"/>
                        <fmt:formatNumber value="${product.buyPrice}" type="currency"/></td>
                    <td><fmt:formatNumber value="${product.sellPrice}" type="currency"/></td>
                    <td>${product.quantityInStock}</td>
                    <td><security:authorize access="hasRole('SUPERADMIN')">
                            <a href="addProduct">Insert</a>
                            <a href="/admin/deleteProduct?code=${product.code}">Delete</a>
                        </security:authorize>
                        <security:authorize access="hasRole('ADMIN')">
                            <a href="addProduct">Insert</a>
                        </security:authorize>
                    </td>

                </tr>
            </c:forEach>
        </table>

    </body>
</html>
当我在jsp页面上单击“删除”时,我得到的url为“http://localhost:8080/admin/deleteProduct?code=fff“但是由于某些原因,代码没有进入删除功能。
感谢的任何帮助

?code
不是
@PathVariable
,而是
@RequestParam
例如
/deleteProduct/{code}
->
http://localhost:8080/admin/deleteProduct/fff
-此处
code
是一个路径变量
@Controller
@RequestMapping("/admin")
public class ProtectedController {

    
    @RequestMapping("/deleteProduct{code}")
    public ModelAndView deleteProduct(@PathVariable ("code") String code){
        System.out.println("Code found ="+code);
        bookService.deleteAProduct(code);
        return new ModelAndView("/allProducts", "productList", bookService.getAllProducts());
    }
    
}