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. }
    21. }

spring mvc中的@PathVariable的更多相关文章

  1. spring mvc中的@PathVariable(转)

    鸣谢:http://jackyrong.iteye.com/blog/2059307 ------------------------------------------------ spring m ...

  2. Spring mvc中@RequestMapping 6个基本用法

    Spring mvc中@RequestMapping 6个基本用法 spring mvc中的@RequestMapping的用法.  1)最基本的,方法级别上应用,例如: Java代码 @Reques ...

  3. Http请求中Content-Type讲解以及在Spring MVC中的应用

    引言: 在Http请求中,我们每天都在使用Content-type来指定不同格式的请求信息,但是却很少有人去全面了解content-type中允许的值有多少,这里将讲解Content-Type的可用值 ...

  4. Spring mvc中@RequestMapping 6个基本用法小结(转载)

    小结下spring mvc中的@RequestMapping的用法. 1)最基本的,方法级别上应用,例如: @RequestMapping(value="/departments" ...

  5. Spring MVC 中的基于注解的 Controller【转】

    原文地址:http://my.oschina.net/abian/blog/128028 终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 H ...

  6. Spring MVC中基于注解的 Controller

         终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 HandlerMapping 来映射出相应的 handler 并调用相应的方法以响 ...

  7. Spring MVC中的HandlerMapping与HandlerAdapter

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  8. Http请求中Content-Type讲解以及在Spring MVC中的应用【转】

    完全引用自: http://blog.csdn.net/blueheart20/article/details/45174399#t1   此文讲得很清晰,赞! 引言: 在Http请求中,我们每天都在 ...

  9. Spring MVC 中 @ModelAttribute 注解的妙用

    Spring MVC 中 @ModelAttribute 注解的妙用 Spring MVC 提供的这种基于注释的编程模型,极大的简化了 web 应用的开发.其中 @Controller 和 @Rest ...

随机推荐

  1. Java里日期转换及日期比较大小

    1.比较日期的大小: DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//创建日期转换对象hh:mm:ss为 ...

  2. Hive 脚本执行

    hive执行脚本 hive -e “sql语句” 会将查询的结果打印在控制台上.  hive -e “sql语句” >> xxx 会将查询的结果重定向到xxx文件中,会显示OK和抓取的数据 ...

  3. Redis源代码分析(十三)--- redis-benchmark性能測试

    今天讲的这个是用来给redis数据库做性能測试的,说到性能測试,感觉这必定是高大上的操作了.redis性能測试.測的究竟是哪方面的性能,怎样測试,通过什么指标反映此次測试的性能好坏呢.以下我通过源代码 ...

  4. 用typeof查看数据类型&&用parseInt解析数字,并求和

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. Metadata publishing for this service is currently disabled.

    Reason 1: In your web.config <service name="A.B.C"> but your class is: namespace A.B ...

  6. Oracle PLSQL通过SMTP发送E-MAIL邮件代码

    登录到SMTPserver发送邮件,支持HTML CREATE OR REPLACE PROCEDURE send_mail(        p_recipient VARCHAR2, -- 邮件接收 ...

  7. UVA10312- Expression Bracketing(Catalan + 递推)

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=1253">题目链接 题意:给出一个序列,长 ...

  8. ping百度不通的解决方案

    1.ping  www.baidu.com unknow baidu.com 第一步,确定是否能ping通网关 第二步,确定是否能直接ping通外网 如ping 8.8.8.8 第三步,如果上面两个都 ...

  9. 【Datastage】Datastage在win10上安装报错:This Application requires one of the following versions of the .NET Framework:v1.1.4322 Do you want to install this .NET Framework version now?

    Datastage在win10上安装报错如下: 这个错误的意思是:.netFramWork的版本不符合要求,于是,我在网上下载了一个版本一致的 下载地址为:http://pan.baidu.com/s ...

  10. VM里面的桥接

      今天我们谈一谈桥接模式,一般的时候,我用的是NAT模式,需要设置另一个虚拟网卡的IP地址,而不是借助本机的物理网卡.   编辑---虚拟网络编辑器 有些时候直接设置桥接到某个网卡可能会不成功,我们 ...