spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便
下面举个例子来解释:(代码片段)~
@RequestMapping(value = "/get/{bodyIndexId}")
public String get(HttpServletRequest request,
HttpServletResponse response, @PathVariable int bodyIndexId) {
BodyIndexDO bodyIndex = bodyIndexService.getById(bodyIndexId);
return "Hello~~~";
}
传入的bodyIndexId,是一个动态参数,所以用 @PathVariable 接受参数之后下面的方法就可以直接调用了,非常方便的~