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. tensorflow BasicRNNCell调试

    运行以下代码,进入~/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/rnn.py和~/anaconda3/lib/python ...

  2. Hibernate级联及控制反转的增删改查

    在JavaHibernate中,双向多对一的操作一直是一个重点难点,本篇文章就是来探讨这个问题. 双向多对一:一个班级对应多个学生,多个学生同属于一个班级,通过班级信息可以查到班级内的学生,通过学生可 ...

  3. demo 微信毛玻璃效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. ACdreamoj 1011(树状数组维护字符串hash前缀和)

    题目链接:http://acdream.info/problem? pid=1019 题意:两种操作,第一种将字符串某个位置的字符换为还有一个字符.另外一种查询某个连续子序列是否是回文串: 解法:有两 ...

  5. php正则表达式基本

    一.正则表达式的组成 1.分隔符,可以是除了字母,数字,反斜线及空白以外的任何字符,比如/,!,#,%,|,~等;通常有/,!,~ 2.表达式:由一些特殊字符和非特殊字符组成. 3.修饰符:用于开启或 ...

  6. Laravel之认证服务

    一.用户认证 配置文件在config/auth.php下 1.添加认证路由 // 认证路由... Route::get('auth/login', 'Auth\AuthController@getLo ...

  7. Android SDK安装时出错“android Failed to rename directory”的解决方法

    Android SDK安装时出错"android Failed to rename directory"的解决的方法     安装Android SDK时遇到Failed to r ...

  8. Yii2数据库分页操作方法介绍

    本章节将介绍怎样怎样创建一个从数据表 country 中获取国家数据并显示出来的页面. 为了实现这个目标,你将会配置一个数据库连接.创建一个活动记录类,而且创建一个操作及一个视图. 贯穿整个章节,你将 ...

  9. JavaScript 转换小技巧

    1.变量转换 看起来很简单,但据我所看到的,使用构造函数,像Array()或者Number()来进行变量转换是常用的做法.始终使用原始数据类型(有时也称为字面量)来转换变量,这种没有任何额外的影响的做 ...

  10. lua学习笔记(十一)

      面向对象编程    对象的实现     在lua中table就是一种对象         1.有自己的状态         2.有自己的唯一标识self         3.有自己的生命周期   ...