Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring:mvcUrl映射错误的id_Java_Spring_Jsp_Spring Mvc - Fatal编程技术网

Java spring:mvcUrl映射错误的id

Java spring:mvcUrl映射错误的id,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,我试图将productId映射到jsp页面中的URL,但该值是错误的。 URL正在返回,但响应正在返回正确的值: 我的jsp代码: <%@ page language="java" contentType="text/html; charset=iso-8859-1" pageEncoding="iso-8859-1"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

我试图将productId映射到jsp页面中的URL,但该值是错误的。 URL正在返回
,但响应正在返回正确的值:

我的jsp代码:

    <%@ page language="java" contentType="text/html; charset=iso-8859-1" pageEncoding="iso-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
        <div>
            ${success}
        </div>
        <table>
            <tr>
                <td>Id</td>
                <td>Titulo</td>
                <td>Valores</td>
    </tr>
    <c:forEach items="${products}" var="product">
        <tr>
            <td>${product.id}</td>
            <td><a href="${spring:mvcUrl('PC#show').arg(0, product.id).build()}">${product.title}</a></td>
            <td>
                <c:forEach items="${product.prices}" var="price">
                    [${price.value} - ${price.bookType}]
                </c:forEach>
            </td>
        </tr>
    </c:forEach>
</table>
我的Java DAO代码:

    public List<Product> list() {
    return manager.createQuery("select distinct(p) from Product p join fetch p.prices", Product.class).getResultList();
}
公共列表(){
return manager.createQuery(“从产品p中选择不同的(p)连接fetch p.prices”,Product.class.getResultList();
}

很遗憾,我看不到您的方法“show”。 我猜您的路径中有一个打印错误:

@RequestMapping("/show{/id}")
//--------------------^^  WRONG
public String show(@PathVariable("id") long id) {
    ...
}
反而

@RequestMapping("/show/{id}")
//--------------------^^  RIGHT

很遗憾,我看不到您的方法“show”。 我猜您的路径中有一个打印错误:

@RequestMapping("/show{/id}")
//--------------------^^  WRONG
public String show(@PathVariable("id") long id) {
    ...
}
反而

@RequestMapping("/show/{id}")
//--------------------^^  RIGHT