【发布时间】:2015-09-25 19:40:33
【问题描述】:
我需要处理类似的请求
www.example.com/student/thisisname?age=23&country=UK&city=London
我只对thisisname 部分和city 参数的值感兴趣。
我有以下 RequestMapping 但它不起作用。我也试过{name}{.*:city}。
@RequestMapping(value = "/{name:.*}{city}", method = RequestMethod.GET)
【问题讨论】:
-
city=London是一个查询参数。使用@RequestParam带注释的方法参数。 -
你可以去@PathVariable,看看这个网址stackoverflow.com/questions/19803731/spring-mvc-pathvariable
-
使用
@PathVariable注解的方法参数。每当您使用 GET 方法在 URL 中传递参数时,请使用 @PathVariable 注释来获取它 -
您确定将学生姓名作为路径变量有意义吗?学生证不是更好吗?
标签: java spring spring-mvc annotations