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. 10 种机器学习算法的要点(附 Python)(转载)

    一.前言 谷歌董事长施密特曾说过:虽然谷歌的无人驾驶汽车和机器人受到了许多媒体关注,但是这家公司真正的未来在于机器学习,一种让计算机更聪明.更个性化的技术 也许我们生活在人类历史上最关键的时期:从使用 ...

  2. Java之基本类库学习

    JAVA基本类库: (一),输入相关 main(String[] args):设置输入参数 输入类:Scanner:Scanner sc=new Scanner(System.in); (二),系统相 ...

  3. fabricjs 高级篇(自定义类型)

    原文:https://www.sitepoint.com/fabric-js-advanced/ <html> <head> <script src='./js/fabr ...

  4. 配置 FIS 来适配 go revel 框架以优化前端缓存策略

    对于前端工程师来说,浏览器缓存优化是个永远的话题.前几天看了知乎上的一个问答:<大公司里怎样开发和部署前端代码?>,深以为然,所以决心使用 FIS 来优化自身的前端文件. 我们的项目使用了 ...

  5. Codeforces #282 div 1 C Helping People 题解

    CF 282 C Helping People 题解 [原题] time limit per test 2 seconds memory limit per test 512 megabytes in ...

  6. PL-SQL 包的创建和应用

     PL-SQL 包的创建和应用 ①简单介绍     包是一组相关过程.函数.变量.常量和游标等PL/SQL程序设计元素的组合,它具有面向对象程序设计语言的特点.是对这些PL/SQL 程序设计元素的 ...

  7. iOS实录:GCD使用小结(一)

    导语:在iOS中,多线程方案有四种:pthread.NSThread.NSOperation & NSOperationQueue 和 GCD,但是开发中GCD使用得最多,本文主要总结一下我使 ...

  8. 性能测试之Tomcat优化

    1.Tomcat最大连接数等配置   Tomcat的server.xml中Context元素的以下参数都是什么意思? <Connector port="8080"maxThr ...

  9. Android学习(二十三)SubMenu 子菜单

    一.SubMenu子菜单 和功能菜单相似,但是可以添加子菜单. 二.实现步骤: 1.通过onCreateOptionsMenu方法创建子菜单,可以通过代码动态创建,也可以通过xml进行创建. 2.通过 ...

  10. [转载]Error -27796: Failed to connect to server

      原文地址:Error -27796: Failed to connect to server "test.shunde.gov.cn:80"作者:蓝小C 问题描述: 使用Loa ...