zoukankan      html  css  js  c++  java
  • @pathVariable的作用(二十二)

      spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下:

      1. @Controller  
      2. public class TestController {  
      3.      @RequestMapping(value="/user/{userId}/roles/{roleId}",method = RequestMethod.GET)  
      4.      public String getLogin(@PathVariable("userId") String userId,  
      5.          @PathVariable("roleId") String roleId){  
      6.          System.out.println("User Id : " + userId);  
      7.          System.out.println("Role Id : " + roleId);  
      8.          return "hello";  
      9.      }  
      10.      @RequestMapping(value="/product/{productId}",method = RequestMethod.GET)  
      11.      public String getProduct(@PathVariable("productId") String productId){  
      12.            System.out.println("Product Id : " + productId);  
      13.            return "hello";  
      14.      }  
      15.      @RequestMapping(value="/javabeat/{regexp1:[a-z-]+}",  
      16.            method = RequestMethod.GET)  
      17.      public String getRegExp(@PathVariable("regexp1") String regexp1){  
      18.            System.out.println("URI Part 1 : " + regexp1);  
      19.            return "hello";  
      20.      }  
  • 相关阅读:
    魔数,常见魔数
    正则表达式 —— 括号与特殊字符
    串行总线 —— I2C、UART、SPI
    OpenCV-Python sift/surf特征匹配与显示
    OpenCV-Python 边缘检测
    python中zip()函数基本用法
    OpenCv-Python 图像滤波
    获取WMI硬件清单
    PowerShell查询sql server
    别名的应用(New-Alias)
  • 原文地址:https://www.cnblogs.com/MaxElephant/p/8176997.html
Copyright © 2011-2022 走看看