Using Map with @PathVariable

Is that map populated with all path variable names and values?

图片[1]-Using Map with @PathVariable - 拾光赋-拾光赋 Photo by
David Martin on
Unsplash

@PathVariable is a Spring annotation which indicates that a method parameter should be bound to a URI template variable. If the method parameter is Map then the map is populated with all path variable names and values.

It has the following optional elements:

  • name — name of the path variable to bind to
  • required — tells whether the path variable is required
  • value — alias for name
@GetMapping(value = "/book/{author}/{title}")
public void process3(@PathVariable Map<String, String> vals) {
logger.info("{}: {}", vals.get("author"), vals.get("title"));
}
@GetMapping(value = "/book/{author}/{title}")
public void process3(@PathVariable Map<String, String> vals) {

   logger.info("{}: {}", vals.get("author"), vals.get("title"));

}
@GetMapping(value = "/book/{author}/{title}") public void process3(@PathVariable Map<String, String> vals) { logger.info("{}: {}", vals.get("author"), vals.get("title")); }

Enter fullscreen mode Exit fullscreen mode

Doc : http://zetcode.com/spring/pathvariable/


原文链接:Using Map with @PathVariable

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
The questions you ask determine the quality of your life.
你生活的品质取决于你所提出的问题
评论 抢沙发

请登录后发表评论

    暂无评论内容