@PathVariable注解
spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: 、
- @Controller
- public class TestController {
- @RequestMapping(value="/user/{userId}/roles/{roleId}",method = RequestMethod.GET)
- public String getLogin(@PathVariable("userId") String userId,
- @PathVariable("roleId") String roleId){
- System.out.println("User Id : " + userId);
- System.out.println("Role Id : " + roleId);
- return "hello";
- }
- @RequestMapping(value="/product/{productId}",method = RequestMethod.GET)
- public String getProduct(@PathVariable("productId") String productId){
- System.out.println("Product Id : " + productId);
- return "hello";
- }
- @RequestMapping(value="/javabeat/{regexp1:[a-z-]+}",
- method = RequestMethod.GET)
- public String getRegExp(@PathVariable("regexp1") String regexp1){
- System.out.println("URI Part 1 : " + regexp1);
- return "hello";
- }
- }
http://jackyrong.iteye.com/blog/2059307 感谢分享,学习了!~
@PathVariable注解的更多相关文章
- @pathvariable 注解
1.4. @PathVariable 注解 带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义 通过 @PathVar ...
- REST风格,@PathVariable注解
REST(Representational State Transfer,表述性状态转移)是一种软件风格.所谓的REST风格可以简单理解为:使用url表示资源时,每个资源都用一个独一无二的url来表示 ...
- @RequestMapping 和@ResponseBody 和 @RequestBody和@PathVariable 注解 注解用法
接下来讲解一下 @RequestMapping 和@ResponseBody 和 @RequestBody和@PathVariable 注解 注解用法 @RequestMapping 为url映射路 ...
- 【SpringMVC】---RequestMapping、Ant 路径、PathVariable 注解、HiddenHttpMethodFilter 过滤器、用 POJO 作为参数
一.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&qu ...
- @PathVariable注解的使用和@Requestparam
一. @PathVariable @PathVariable这是一个路径映射格式的书写方式注解,在类映射路径的后加上/{对应方法参数中属性@PathVariable("code") ...
- @RequestParam,@RequestBody,@ResponseBody,@PathVariable注解的一点小总结
一.前提知识: http协议规定一次请求对应一次响应,根据不同的请求方式,请求的内容会有所不同: 发送GET请求是没有请求体的,参数会直接拼接保留到url后一并发送: 而POST请求是带有请求体的,带 ...
- @RequestParam,@RequestBody,@PathVariable注解还分不清吗?
前言 在使用 SpringMVC 开发时,经常遇到前端传递的各种参数,比如 form 表单,JSON 数据,String[] 数组,再或者是最常见的 String 字符串等等,总之大部分场景都是在标题 ...
- Spring MVC @PathVariable注解
下面用代码来演示@PathVariable传参方式 @RequestMapping("/user/{id}") public String test(@PathVariable(& ...
- @PathVariable注解的使用
带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义. 通过 @PathVariable 可以将 URL 中占位符参数绑 ...
随机推荐
- HTML学习笔记——post表单
1>form1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...
- Servlet之Filter详解
参考文献:http://www.cnblogs.com/zlbx/p/4888312.html Filter,过滤器,顾名思义,即是对数据等的过滤,预处理过程.为什么要引入过滤器呢?在平常访问网站的时 ...
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【六】——实现资源间的关联
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 这一篇文章主要介绍一下资源间的关联——例如在学生和课程之间就存在这样的关联:每一个课程都会有 ...
- 入门:PHP:hello world!
<?php echo 'hello'."\n"." world!"."good night!";//2016.09.18 22:57? ...
- JS实现的一个query字符串转Json格式数据的方法
输入字符串的格式是 a=1&b=2&c=3 $.par2Json = function (string, overwrite) { var obj = {}, pairs = stri ...
- UnExpected Error, Quitting
UnExpected Error, Quitting VB在win7 环境安装后,启动vb6.0弹出以上英文提示,目前解决方法: 下载动态库,放置于C:\ProgramFiles\Common Fil ...
- cdn提供商
七牛,又拍 http://www.qiniu.com/ https://www.upyun.com/index.html
- ASP.NET WebForm中用async/await实现异步
1. 在.aspx中添加异步标记 <%@ Page Language="C#" Async="true"%> 2. 在.aspx.cs或者.ascx ...
- 捕获EF提交异常
try { } catch (DbEntityValidationException dbex) { string errMsg = string.Empty; foreach (var eve in ...
- Think in Java(Java编程思想)-第2章 一切都是对象
1. String s = "asdf"//创建一个String引用,并初始化. String s = new String("asdf")//创建一个新对象, ...