blueskyzs
blueskyzs
采纳率25%
2017-05-04 02:10

springmvc 一个controller方法怎么处理多个请求地址?

已采纳

举个例子:
/details/{actid}
/details/{actid}/{sku}
我想让这两个地址都被一个controller方法处理,我实验了一下,不行啊,请同学知道么
@RequestMapping(value={"/details/{actId}", "/details/{actId}/{sku}"}, method = RequestMethod.GET)
public String details(@PathVariable("actId") Integer actId, @PathVariable("sku") String sku, Model model) {
System.out.println("actId = " + actId + ", sku = " + sku);
return "/act/details";
}


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

相关推荐