<tr><td>商品名称</td><td>商品图片</td><td>商品原价</td><td>秒杀价</td><td>库存数量</td><td>详情</td></tr>
<tr th:each="goods,goodsStat : ${goodsList}">
<td th:text="${goods.goodsName}"></td>
<td ><img th:src="@{${goods.goodsImg}}" width="100" height="100" /></td>
<td th:text="${goods.goodsPrice}"></td>
<td th:text="${goods.miaoshaPrice}"></td>
<td th:text="${goods.stockCount}"></td>
<td><a th:href="'/goods_detail.htm?goodsId='+${goods.id}">详情</a></td>
</tr>
<td><a th:href="'/goods_detail.htm?goodsId='+${goods.id}">详情</a></td>
为什么可以和Controller中的"/goods/detail/{goodsId}"匹配呢??感觉这种href的作用不是跳转页面吗,为什么会转到Controller?
@Controller
@Slf4j
@RequestMapping("/goods") //
public class GoodsController extends BaseController
@RequestMapping(value="/detail/{goodsId}") //GoodsController类中的方法
@ResponseBody
public Result<GoodsDetailVo> detail(HttpServletRequest request, HttpServletResponse response, Model model, MiaoshaUser user,@PathVariable("goodsId")long goodsId)
template中是goods_detail.html 为什么th:href中写的是goods_detail.htm?而且如果改成.html就会无法与controller匹配上,有没有人可以解答?
th:href="'/goods_detail.htm?goodsId='+${goods.id}
为什么可以和Controller中的"/goods/detail/{goodsId}"匹配呢??
这个要看你的配置,你配置中配置了,接口后缀是.htm
template目录下的模版页面好像不能直接访问,需要通过接口返回。