Java spring:mvcUrl映射错误的id
我试图将productId映射到jsp页面中的URL,但该值是错误的。 URL正在返回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"%>
,但响应正在返回正确的值:
我的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