最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
spring mvc中的@PathVariable获得请求url中的动态参数
时间:2022-06-25 08:48:27 编辑:袖梨 来源:一聚教程网
spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下:
代码如下 | 复制代码 |
@Controller publicclassTestController { @RequestMapping(value="/user/{userId}/roles/{roleId}",method = RequestMethod.GET) publicString getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId){ System.out.println("User Id : "+ userId); System.out.println("Role Id : "+ roleId); return"hello"; } @RequestMapping(value="/product/{productId}",method = RequestMethod.GET) publicString getProduct(@PathVariable("productId") String productId){ System.out.println("Product Id : "+ productId); return"hello"; } @RequestMapping(value="/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET) publicString getRegExp(@PathVariable("regexp1") String regexp1){ System.out.println("URI Part 1 : "+ regexp1); return"hello"; } } |
相关文章
- 英雄联盟手游豹女符文怎么带2025-狂野女猎手奈德丽符文搭配推荐 09-15
- 无限暖暖家园万象星实获取攻略 09-15
- 英雄联盟手游克格莫连招教学 09-15
- 英雄联盟手游克格莫符文加点推荐 09-15
- 重返未来1999未锈铠狂想介绍 09-15
- 重返未来1999好梦井玩法介绍 09-15