@PathVariable的作用?
答:
先看下面的例子
@RequestMapping(
value = {"/systems/{subSystem}/index.html"},
method = {RequestMethod.GET}
)
public ModelAndView subSystemIndex(@PathVariable String subSystem) {
String subSystemIndex = "/systems/" + subSystem + "/index";
ModelAndView mav = new ModelAndView(subSystemIndex);
mav.addAllObjects(menus);
return mav;
}
@PathVariable获取请求路径中的参数subSystem作为请求方法的参数,在方法中使用。
假如请求地址为http://localhost:18082/systems/process/index.html,那么subSystem就等于process。
本文地址:http://www.yayihouse.com/yayishuwu/chapter/1280