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. 前端打包利器:webpack工具

    一.什么是WebPack,为什么要使用它? 1.为什要使用WebPack 现今的很多网页其实可以看做是功能丰富的应用,它们拥有着复杂的JavaScript代码和一大堆依赖包.为了简化开发的复杂度,前端 ...

  2. EasyUI Tree 动态传递参数

    1.问题背景 一般出现在加载的时候,传递参数给后台,进行数据筛选,然后在加载tree渲染数据.所谓动态参数,可以是你的上一级节点node,或者是根节点node. 2.涉及方法 onBeforeLoad ...

  3. Oracle基础 触发器

    一.触发器 触发器是当特定事件出现时自动执行的代码块.比如,每次对员工表进行增删改的操作时,向日志表中添加一条记录.触发器和存储过程是由区别的:触发器是根据某些条件自动执行的,存储过程是手动条用的. ...

  4. CentOS——yum命令运行错误解决办法

    问题: [root@name user]# yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:        ...

  5. mysql热备及查询mysql操作日志

    mysql热备 1 查看mysql版本,保证主库低于等于从库 2 主库配置:   A 需要打开支持日志功能:log-bin=mysql-bin   B 提供server-id:server-id=1  ...

  6. <转>创建支持eclipse的多模块maven项目

    如何使用eclipse创建Maven工程及其子模块 1,首先创建一个父类工程   子模块继承父类工程      并在父类工程的pom.xml文件中定义引入的jar及其版本号     子模块可以引用 2 ...

  7. SVN遇到Can't convert string from 'UTF-8' to native encoding(转)

    svn: Can't convert string from 'UTF-8' to native encoding: svn: platform/console-framework/portal/im ...

  8. 【VAB】获取库文件地址

    如何获取Excle库文件地址呢?具体代码如下: Public Sub 获取Excel库文件夹的路径() MsgBox "库文件夹的路径是: " & Application. ...

  9. JUnit单元测试中的setUpBeforeClass()、tearDownAfterClass()、setUp()、tearDown()方法小结

    编写JUnit单元测试的时候,会用到 setUpBeforeClass().tearDownAfterClass().setUp().tearDown()这四个方法,例如用 eclipse新建一个ju ...

  10. 【Lucene】Apache Lucene全文检索引擎架构之构建索引2

    上一篇博文中已经对全文检索有了一定的了解,这篇文章主要来总结一下全文检索的第一步:构建索引.其实上一篇博文中的示例程序已经对构建索引写了一段程序了,而且那个程序还是挺完善的.不过从知识点的完整性来考虑 ...