`
流浪鱼
  • 浏览: 1624485 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

@PathVariable 绑定URI 模板变量值

 
阅读更多

@PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上。

@RequestMapping(value="/users/{userId}/topics/{topicId}")
public String test(
@PathVariable(value="userId") int userId,
@PathVariable(value="topicId") int topicId)

如请求的 URL 为“控制器URL/users/123/topics/456”,则自动将URL 中模板变量{userId}和{topicId}绑定到通过

@PathVariable注解的同名参数上,即入参后userId=123、topicId=456 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics