PathVariable

来源:互联网 发布:手机淘宝没有实名认证 编辑:程序博客网 时间:2024/05/15 03:16
@RequestMapping(value = "/detail-index", method = RequestMethod.GET)
    public ModelAndView detail(HttpServletRequest request, HttpServletResponse response, @PathVariable("tab") String tab) {
        AuthedUser user = CookieUtils.getLoginUser(request, response);
        Map<String, Object> model = getModel(request);
        model.put("__user", user);
        return mv("detail/detail-index", model);

    }


当函数参数中设置了PathVariable时,请求路径必须为/detail-index/{tab},否则请求报404错误,当然这个小地方通过对比其它函数就可以得出结论,但也算是自己踩到不懂的坑,,mark一下。

1 0
原创粉丝点击