@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 

猜你喜欢

转载自liuna718-163-com.iteye.com/blog/2215921
今日推荐